List of usage examples for android.widget TabHost newTabSpec
@NonNull
public TabSpec newTabSpec(@NonNull String tag)
From source file:com.android.packageinstaller.GrantActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); mPm = getPackageManager();// ww w . j av a2 s .co m mRequestingPackage = this.getCallingPackage(); requested_permissions = getRequestedPermissions(); if (requested_permissions.length == 0) { // The grant request was empty. Return success setResult(RESULT_OK); finish(); return; } PackageInfo pkgInfo = getUpdatedPackageInfo(); AppSecurityPermissions perms = new AppSecurityPermissions(this, pkgInfo); if (perms.getPermissionCount(AppSecurityPermissions.WHICH_NEW) == 0) { // The updated permissions dialog said there are no new permissions. // This should never occur if requested_permissions.length > 0, // but we check for it anyway, just in case. setResult(RESULT_OK); finish(); return; } setContentView(R.layout.install_start); ((TextView) findViewById(R.id.install_confirm_question)).setText(R.string.grant_confirm_question); PackageUtil.AppSnippet as = new PackageUtil.AppSnippet(mPm.getApplicationLabel(pkgInfo.applicationInfo), mPm.getApplicationIcon(pkgInfo.applicationInfo)); PackageUtil.initSnippetForNewApp(this, as, R.id.app_snippet); mOk = (Button) findViewById(R.id.ok_button); mOk.setText(R.string.ok); mCancel = (Button) findViewById(R.id.cancel_button); mOk.setOnClickListener(this); mCancel.setOnClickListener(this); TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost); tabHost.setup(); ViewPager viewPager = (ViewPager) findViewById(R.id.pager); TabsAdapter adapter = new TabsAdapter(this, tabHost, viewPager); View newTab = perms.getPermissionsView(AppSecurityPermissions.WHICH_NEW); View allTab = getPermissionList(perms); adapter.addTab(tabHost.newTabSpec("new").setIndicator(getText(R.string.newPerms)), newTab); adapter.addTab(tabHost.newTabSpec("all").setIndicator(getText(R.string.allPerms)), allTab); }
From source file:com.android.inputmethod.keyboard.emoji.EmojiPalettesView.java
private void addTab(final TabHost host, final int categoryId) { final String tabId = EmojiCategory.getCategoryName(categoryId, 0 /* categoryPageId */); final TabHost.TabSpec tspec = host.newTabSpec(tabId); tspec.setContent(R.id.emoji_keyboard_dummy); final ImageView iconView = (ImageView) LayoutInflater.from(getContext()) .inflate(R.layout.emoji_keyboard_tab_icon, null); // TODO: Replace background color with its own setting rather than using the // category page indicator background as a workaround. iconView.setBackgroundColor(mCategoryPageIndicatorBackground); iconView.setImageResource(mEmojiCategory.getCategoryTabIcon(categoryId)); iconView.setContentDescription(mEmojiCategory.getAccessibilityDescription(categoryId)); tspec.setIndicator(iconView);/*from w ww. j a v a 2 s . c om*/ host.addTab(tspec); }
From source file:net.line2soft.preambul.views.ExcursionInfoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { //Check if this version of Android allows to use custom title bars boolean feature = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); /** Set layout **/ //Base layout super.onCreate(savedInstanceState); setContentView(R.layout.activity_excursion_info); //set title bar if (feature) { getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.activity_title_bar); TextView myTitleText = (TextView) findViewById(R.id.textView0); myTitleText.setText(getString(R.string.title_activity_excursion_info)); }/*from ww w .j av a 2 s .com*/ //Get excursion ID int id = getIntent().getIntExtra(ExcursionListActivity.EXCURSION_ID, 0); if (id > 0) { //Set listener listener = new ExcursionInfoListener(this); //Set tabs TabHost tabHost = (TabHost) findViewById(R.id.tabHost); tabHost.setup(); TabSpec spec1 = tabHost.newTabSpec("Info"); spec1.setContent(R.id.tab1); spec1.setIndicator("", getResources().getDrawable(R.drawable.description_tab)); spec1.setContent(R.id.tab1); TabSpec spec2 = tabHost.newTabSpec("POI"); spec2.setIndicator("", getResources().getDrawable(R.drawable.pois_tab)); spec2.setContent(R.id.tab2); TabSpec spec3 = tabHost.newTabSpec("Instructions"); spec3.setIndicator("", getResources().getDrawable(R.drawable.instruction_tab)); spec3.setContent(R.id.tab3); TabSpec spec4 = tabHost.newTabSpec("Photos"); spec4.setIndicator("", getResources().getDrawable(R.drawable.photos_tab)); spec4.setContent(R.id.tab4); tabHost.addTab(spec1); tabHost.addTab(spec2); tabHost.addTab(spec3); tabHost.addTab(spec4); //set the info tab try { Excursion exc = MapController.getInstance(this).getCurrentLocation().getExcursions(this).get(id); //Display locomotions Locomotion[] locomotionsItems = exc.getLocomotions(); LinearLayout locomotionsLayout = (LinearLayout) findViewById(R.id.locomotionsLayout); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); for (int i = 0; i < locomotionsItems.length; i++) { if (locomotionsItems[i].getIcon() == null) { //Define icon if undefined int imageResource = getResources().getIdentifier( "locomotion_" + locomotionsItems[i].getKey(), "drawable", getPackageName()); if (imageResource != 0) { Drawable ic = getResources().getDrawable(imageResource); locomotionsItems[i].setIcon(ic); } } ImageView img = (ImageView) inflater.inflate(R.layout.locomotion_item, null); img.setImageDrawable(locomotionsItems[i].getIcon()); locomotionsLayout.addView(img); } int value = exc.getDifficulty(); if (value == Excursion.DIFFICULTY_NONE) { ImageView view = (ImageView) findViewById(R.id.ImageView2); view.setImageResource(R.drawable.difficulte1); } else if (value == Excursion.DIFFICULTY_EASY) { ImageView view = (ImageView) findViewById(R.id.ImageView2); view.setImageResource(R.drawable.difficulte2); } else if (value == Excursion.DIFFICULTY_MEDIUM) { ImageView view = (ImageView) findViewById(R.id.ImageView2); view.setImageResource(R.drawable.difficulte3); } else if (value == Excursion.DIFFICULTY_HARD) { ImageView view = (ImageView) findViewById(R.id.ImageView2); view.setImageResource(R.drawable.difficulte4); } else if (value == Excursion.DIFFICULTY_EXPERT) { ImageView view = (ImageView) findViewById(R.id.ImageView2); view.setImageResource(R.drawable.difficulte5); } String time = ExcursionAdapter.convertTime(exc.getTime()); TextView view = (TextView) findViewById(R.id.textView1); view.setText(time); Double length = Double.valueOf(exc.getLength() / 1000); String lengthString = length.toString().substring(0, length.toString().lastIndexOf(".") + 2) + " km"; view = (TextView) findViewById(R.id.textView2); view.setText(lengthString); view = (TextView) findViewById(R.id.textView3); view.setText(exc.getDescription()); } catch (Exception e) { e.printStackTrace(); onBackPressed(); displayInfo(getString(R.string.message_excursion_not_found)); } MapController exc = MapController.getInstance(this); //set the POI tab try { PointOfInterest[] pois = exc.getCurrentLocation().getExcursions(this).get(id) .getSurroundingPois(this); List<NamedPoint> itemsList = Arrays.asList(((NamedPoint[]) pois)); Collections.sort(itemsList, new NamedPointComparator()); pois = itemsList.toArray(new PointOfInterest[itemsList.size()]); if (pois.length > 0) { ListView listPoi = (ListView) findViewById(R.id.listView2); listPoi.setAdapter(new FavoriteAdapter(getLayoutInflater(), pois, this)); listPoi.setOnItemClickListener(listener); listPoi.setVisibility(View.VISIBLE); findViewById(R.id.NoPOIs).setVisibility(View.GONE); } } catch (Exception e) { e.printStackTrace(); System.err.println("Couldn't fill POI tab"); } //set the instruction tab ListView list = (ListView) findViewById(R.id.listView1); if (list != null) { try { NavigationInstruction[] instructions = exc.getCurrentLocation().getExcursions(this).get(id) .getInstructions(); if (instructions.length != 0) { ((TextView) findViewById(R.id.NoInstructions)).setVisibility(View.GONE); } list.setAdapter(new ExcursionInfoInstructionAdapter(this, instructions)); list.setOnItemClickListener(listener); } catch (Exception e) { e.printStackTrace(); } } //Set the picture tab String imagePath = Environment.getExternalStorageDirectory().getPath() + File.separator + "Android" + File.separator + "data" + File.separator + "net.line2soft.preambul" + File.separator + "files" + File.separator + MapController.getInstance(this).getCurrentLocation().getId() + File.separator + "excursions" + File.separator + getIntent().getIntExtra(ExcursionListActivity.EXCURSION_ID, 0); FileFilter filter = new FileFilter() { @Override public boolean accept(File file) { return file.getAbsolutePath().matches(".*\\.jpg"); } }; imagesFile = new File(imagePath).listFiles(filter); ((TextView) findViewById(R.id.NoPhotos)).setVisibility(View.VISIBLE); if (imagesFile != null) { if (imagesFile.length > 0) { ((TextView) findViewById(R.id.NoPhotos)).setVisibility(View.GONE); ImagePagerAdapter adapter = new ImagePagerAdapter(getSupportFragmentManager(), imagesFile, this); ViewPager myPager = (ViewPager) findViewById(R.id.pager_images); myPager.setAdapter(adapter); myPager.setOnPageChangeListener(listener); //Set listener on right and left buttons in picture tab (findViewById(R.id.imageRight)).setOnClickListener(listener); (findViewById(R.id.imageLeft)).setOnClickListener(listener); //Change visibility of these buttons ImageView right = (ImageView) findViewById(R.id.imageRight); ImageView left = (ImageView) findViewById(R.id.imageLeft); left.setVisibility(View.INVISIBLE); right.setVisibility(View.INVISIBLE); int idPhoto = ((ViewPager) findViewById(R.id.pager_images)).getCurrentItem(); int nbPhotos = getImagesFile().length; if (idPhoto != nbPhotos - 1) { right.setVisibility(View.VISIBLE); } } } //Set listener on launch button Button launch = (Button) findViewById(R.id.button_load_excursion); launch.setOnClickListener(listener); } else { onBackPressed(); displayInfo(getString(R.string.message_excursion_not_found)); } }
From source file:fr.mixit.android.ui.StarredActivity.java
/** Build and add "speakers" tab. */ private void setupSpeakersTab() { final TabHost host = getTabHost(); final Intent intent = new Intent(Intent.ACTION_VIEW, MixItContract.Speakers.CONTENT_STARRED_URI); intent.addCategory(Intent.CATEGORY_TAB); // Speakers content comes from reused activity host.addTab(host.newTabSpec(TAG_SPEAKERS).setIndicator(buildIndicator(R.string.starred_speakers)) .setContent(intent));//from w w w. j a v a2s .c o m }
From source file:com.initiativaromania.hartabanilorpublici.IRUserInterface.activities.MainActivity.java
private void tabSetup() { TabHost tabHost = (TabHost) findViewById(R.id.tabHost); tabHost.setup();// w w w . j av a 2s . c om View tabView = createTabView(this, TAB_MAP); TabHost.TabSpec spec = tabHost.newTabSpec("tab1").setIndicator(tabView).setContent(R.id.tabMap); tabHost.addTab(spec); tabView = createTabView(this, TAB_STATISTICS); spec = tabHost.newTabSpec("tab2").setIndicator(tabView).setContent(R.id.tabStatistics); tabHost.addTab(spec); }
From source file:com.google.android.apps.iosched.ui.SessionDetailActivity.java
/** Build and add "summary" tab. */ private void setupSummaryTab() { final TabHost host = getTabHost(); // Summary content comes from existing layout host.addTab(host.newTabSpec(TAG_SUMMARY).setIndicator(buildIndicator(R.string.session_summary)) .setContent(R.id.tab_session_summary)); }
From source file:org.exobel.routerkeygen.ui.Preferences.java
protected Dialog onCreateDialog(int id) { AlertDialog.Builder builder = new Builder(this); switch (id) { case DIALOG_ABOUT: { LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.about_dialog, (ViewGroup) findViewById(R.id.tabhost)); TabHost tabs = (TabHost) layout.findViewById(R.id.tabhost); tabs.setup();/*www .jav a2s . co m*/ TabSpec tspec1 = tabs.newTabSpec("about"); tspec1.setIndicator(getString(R.string.pref_about)); tspec1.setContent(R.id.text_about_scroll); TextView text = ((TextView) layout.findViewById(R.id.text_about)); text.setMovementMethod(LinkMovementMethod.getInstance()); text.append(VERSION + "\n" + LAUNCH_DATE); tabs.addTab(tspec1); TabSpec tspec2 = tabs.newTabSpec("credits"); tspec2.setIndicator(getString(R.string.dialog_about_credits)); tspec2.setContent(R.id.about_credits_scroll); ((TextView) layout.findViewById(R.id.about_credits)) .setMovementMethod(LinkMovementMethod.getInstance()); tabs.addTab(tspec2); TabSpec tspec3 = tabs.newTabSpec("license"); tspec3.setIndicator(getString(R.string.dialog_about_license)); tspec3.setContent(R.id.about_license_scroll); ((TextView) layout.findViewById(R.id.about_license)) .setMovementMethod(LinkMovementMethod.getInstance()); tabs.addTab(tspec3); builder.setNeutralButton(R.string.bt_close, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { removeDialog(DIALOG_ABOUT); } }); builder.setView(layout); break; } case DIALOG_ASK_DOWNLOAD: { DialogInterface.OnClickListener diOnClickListener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // Check if we have the latest dictionary version. try { checkCurrentDictionary(); } catch (Exception e) { e.printStackTrace(); } } }; builder.setTitle(R.string.pref_download); builder.setMessage(R.string.msg_dicislarge); builder.setCancelable(false); builder.setPositiveButton(android.R.string.yes, diOnClickListener); builder.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { removeDialog(DIALOG_ASK_DOWNLOAD); } }); break; } case DIALOG_UPDATE_NEEDED: { builder.setTitle(R.string.update_title) .setMessage(getString(R.string.update_message, lastVersion.version)) .setNegativeButton(R.string.bt_close, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { removeDialog(DIALOG_UPDATE_NEEDED); } }).setPositiveButton(R.string.bt_website, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(lastVersion.url))); } }); break; } case DIALOG_WAIT: { ProgressDialog pbarDialog = new ProgressDialog(Preferences.this); pbarDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); pbarDialog.setMessage(getString(R.string.msg_wait)); return pbarDialog; } case DIALOG_ERROR_TOO_ADVANCED: { builder.setTitle(R.string.msg_error).setMessage(R.string.msg_err_online_too_adv); break; } case DIALOG_ERROR: { builder.setTitle(R.string.msg_error).setMessage(R.string.msg_err_unkown); break; } case DIALOG_CHANGELOG: { LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); ChangeLogListView chgList = (ChangeLogListView) layoutInflater.inflate(R.layout.dialog_changelog, (ViewGroup) this.getWindow().getDecorView().getRootView(), false); builder.setTitle(R.string.pref_changelog).setView(chgList).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }); break; } } return builder.create(); }
From source file:azad.hallaji.farzad.com.masirezendegi.ExplainMoshaver.java
void postgetData() { ProgressBar progressbarsandaha = (ProgressBar) findViewById(R.id.progressbarsandaha); progressbarsandaha.setVisibility(View.VISIBLE); MyRequestQueue = Volley.newRequestQueue(this); String url = "http://telyar.dmedia.ir/webservice/Get_adviser_profile/"; StringRequest MyStringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() { @Override//from ww w .j av a2 s. c o m public void onResponse(String response) { //This code is executed if the server responds, whether or not the response contains data. //The String 'response' contains the server's response. Log.i("ExplainMoshaver", response); //Toast.makeText(getApplicationContext(), response , Toast.LENGTH_LONG).show(); updatelistview(response); } }, new Response.ErrorListener() { //Create an error listener to handle errors appropriately. @Override public void onErrorResponse(VolleyError error) { //This code is executed if there is an error. } }) { protected Map<String, String> getParams() { Map<String, String> MyData = new HashMap<String, String>(); //Log.i("asasasasasasa",adviseridm+"/"+GlobalVar.getDeviceID()); MyData.put("adviserid", adviseridm); //Add the data you'd like to send to the server. MyData.put("deviceid", GlobalVar.getDeviceID()); //Add the data you'd like to send to the server. MyData.put("userid", GlobalVar.getUserID()); //Add the data you'd like to send to the server. Log.i("ExplainMoshaver", MyData.toString()); return MyData; } @Override protected void onFinish() { ProgressBar progressbarsandaha = (ProgressBar) findViewById(R.id.progressbarsandaha); progressbarsandaha.setVisibility(View.INVISIBLE); TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost); TabHost.TabSpec tabSpec3 = tabHost.newTabSpec("nazar"); TabHost.TabSpec tabSpec2 = tabHost.newTabSpec("madarek"); TabHost.TabSpec tabSpec1 = tabHost.newTabSpec("map"); tabSpec3.setIndicator(""); Intent intent1 = new Intent(ExplainMoshaver.this, ListeComments.class); intent1.putExtra("adviseridm", adviseridm); intent1.putExtra("comments", comments); /*intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent1.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); intent1.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);*/ Log.i("aaaaaaaaaaaaaaa", comments + " "); tabSpec3.setContent(intent1); tabSpec2.setIndicator(""); Intent intent2 = new Intent(ExplainMoshaver.this, ListeLiecence.class); intent2.putExtra("adviseridm", adviseridm); intent2.putExtra("License", License); /*intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); intent2.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);*/ tabSpec2.setContent(intent2); tabSpec1.setIndicator(""); final Intent intent = new Intent(ExplainMoshaver.this, MapsActivity.class); intent.putExtra("adviseridm", adviseridm); intent.putExtra("Mainplace", Mainplace); intent.putExtra("menuya", "ya"); /*intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);*/ tabSpec1.setContent(intent); tabHost.addTab(tabSpec1); tabHost.addTab(tabSpec2); tabHost.addTab(tabSpec3); tabHost.setCurrentTab(2); } }; MyRequestQueue.add(MyStringRequest); }
From source file:com.redhorse.quickstart.AppConfig.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); dbStart = new dbStartConfigAdapter(this); dbStart.open();//from w w w . j av a2s .co m loadApps(); // do this in onresume? setContentView(R.layout.applist); TabHost mTabHost = (TabHost) findViewById(R.id.tabhost); mTabHost.setup(); LayoutInflater inflater_tab1 = LayoutInflater.from(this); inflater_tab1.inflate(R.layout.grid1, mTabHost.getTabContentView()); inflater_tab1.inflate(R.layout.grid2, mTabHost.getTabContentView()); mTabHost.addTab(mTabHost.newTabSpec("tab_test1") .setIndicator("", getResources().getDrawable(R.drawable.btn_add)).setContent(R.id.list1)); mTabHost.addTab(mTabHost.newTabSpec("tab_test2") .setIndicator("", getResources().getDrawable(R.drawable.btn_remove)).setContent(R.id.list2)); mList = (GridView) findViewById(R.id.list1); mList.setAdapter(new AppsAdapter()); mList.setOnItemClickListener(Grid1ItemClickListener); mList2 = (GridView) findViewById(R.id.list2); mList2.setAdapter(new AppsAdapter2()); mList2.setOnItemClickListener(Grid2ItemClickListener); Button button = (Button) findViewById(R.id.Button01); button.setOnClickListener(Button01Listener); button = (Button) findViewById(R.id.Button02); button.setOnClickListener(Button02Listener); button = (Button) findViewById(R.id.weibolist); button.setOnClickListener(weibolistListener); }
From source file:com.tutor.fragment.ViewPageFragment.java
private void initialMainTabHost(LayoutInflater inflater, View mView) { View sgTab = inflater.inflate(R.layout.tab_main_widebg, null); TextView sgtv = (TextView) sgTab.findViewById(R.id.mainTabTv); sgtv.setText("3G"); View yxTab = inflater.inflate(R.layout.tab_main_widebg, null); TextView yxtv = (TextView) yxTab.findViewById(R.id.mainTabTv); yxtv.setText(""); TabHost yxTabHost = (TabHost) mView.findViewById(R.id.yxTabHost); yxTabHost.setup();//from w w w. j a v a2 s. com yxTabHost.addTab(yxTabHost.newTabSpec("3GTab").setIndicator(sgTab).setContent(R.id.tab_3gfudao)); yxTabHost.addTab(yxTabHost.newTabSpec("YXJifen").setIndicator(yxTab).setContent(R.id.tab_yxjifen)); yxTabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { if (tabId.equals("3GTab")) { // ListView myTabLst = (ListView) // findViewById(R.id.myTabLst); } else { } } }); }