Java Code Examples for android.widget.TabHost#setup()
The following examples show how to use
android.widget.TabHost#setup() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GestionAlumnos.java From android with GNU General Public License v2.0 | 6 votes |
private void cargaPestanas() { Resources res = getResources(); TabHost tabHost = (TabHost) findViewById(R.id.tabhost); tabHost.setup(); TabSpec tbListadoAlumnos = tabHost.newTabSpec(res.getString(R.string.listado_alumnos_title)); tbListadoAlumnos.setContent(R.id.tab1); tbListadoAlumnos.setIndicator(res.getString(R.string.listado_alumnos_title), res.getDrawable(android.R.drawable.ic_menu_slideshow)); tabHost.addTab(tbListadoAlumnos); TabSpec tbNuevoAlumno = tabHost.newTabSpec(res.getString(R.string.nuevo_alumno_title)); tbNuevoAlumno.setContent(R.id.tab2); tbNuevoAlumno.setIndicator(res.getString(R.string.nuevo_alumno_title), res.getDrawable(android.R.drawable.ic_menu_edit)); tabHost.addTab(tbNuevoAlumno); tabHost.setCurrentTab(0); tabHost.setOnTabChangedListener(this); }
Example 2
Source File: FragmentTabsPager.java From V.FlyoutTest with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_tabs_pager); mTabHost = (TabHost)findViewById(android.R.id.tabhost); mTabHost.setup(); mViewPager = (ViewPager)findViewById(R.id.pager); mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager); mTabsAdapter.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"), FragmentStackSupport.CountingFragment.class, null); mTabsAdapter.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"), LoaderCursorSupport.CursorLoaderListFragment.class, null); mTabsAdapter.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"), LoaderCustomSupport.AppListFragment.class, null); mTabsAdapter.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"), LoaderThrottleSupport.ThrottledLoaderListFragment.class, null); if (savedInstanceState != null) { mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab")); } }
Example 3
Source File: MainActivity.java From android_tv_metro with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTabHost = (TabHost)findViewById(android.R.id.tabhost); mTabHost.setup(); mTabs = (TabWidget)findViewById(android.R.id.tabs); ViewStub vStub = (ViewStub) findViewById(R.id.new_home_menu); mMenuContainer = (FrameLayout) vStub.inflate(); mViewPager = (ViewPager)findViewById(R.id.pager); mLoadingView = makeEmptyLoadingView(this, (RelativeLayout)findViewById(R.id.tabs_content)); setScrollerTime(800); albumItem = (DisplayItem) getIntent().getSerializableExtra("item"); setUserFragmentClass(); getSupportLoaderManager().initLoader(TabsGsonLoader.LOADER_ID, null, this); if (savedInstanceState != null) { mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab")); } }
Example 4
Source File: MainActivity.java From iTab with Apache License 2.0 | 5 votes |
private void setTabs() { mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); addTab("Home", TAG_1, createTabDrawable(R.drawable.home), R.id.text_view_home); addTab("Search", TAG_2, createTabDrawable(R.drawable.search), R.id.text_view_search); addTab("Favourites", TAG_3, createTabDrawable(R.drawable.star), R.id.text_view_favourites); addTab("Settings", TAG_4, createTabDrawable(R.drawable.settings), R.id.text_view_settings); }
Example 5
Source File: QoSTestDetailPagerFragment.java From open-rmbt with Apache License 2.0 | 5 votes |
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View v = inflater.inflate(R.layout.result_tabhost_pager, container, false); tabHost = (TabHost) v.findViewById(android.R.id.tabhost); tabHost.setup(); tabHost.setOnTabChangedListener(this); for (int i = 0; i < pagerAdapter.getCount(); i++) { TabSpec tab = tabHost.newTabSpec(String.valueOf(i)); //tab.setIndicator(getActivity().getResources().getStringArray(R.array.result_page_title)[i]); tab.setContent(android.R.id.tabcontent); View indicator = inflater.inflate(R.layout.tabhost_indicator, null); TextView title = (TextView) indicator.findViewById(android.R.id.title); title.setText(pagerAdapter.getPageTitle(i)); tab.setIndicator(indicator); tabHost.addTab(tab); } viewPager = (ExtendedViewPager) v.findViewById(R.id.pager); viewPager.setAdapter(pagerAdapter); viewPager.setOnPageChangeListener(this); setCurrentPosition(0); scroller = (HorizontalScrollView) v.findViewById(R.id.tabwidget_scrollview); viewPager.setCurrentItem(initPageIndex); return v; }
Example 6
Source File: RMBTResultPagerFragment.java From open-rmbt with Apache License 2.0 | 5 votes |
private View createView(View v, LayoutInflater inflater, int currentPage) { tabHost = (TabHost) v.findViewById(android.R.id.tabhost); tabHost.setup(); tabHost.setOnTabChangedListener(this); for (int i = 0; i < pagerAdapter.getCount(); i++) { TabSpec tab = tabHost.newTabSpec(String.valueOf(i)); //tab.setIndicator(getActivity().getResources().getStringArray(R.array.result_page_title)[i]); tab.setContent(android.R.id.tabcontent); View indicator = inflater.inflate(R.layout.tabhost_indicator, null); TextView title = (TextView) indicator.findViewById(android.R.id.title); title.setText(getActivity().getResources().getStringArray(R.array.result_page_title)[RMBTResultPagerAdapter.RESULT_PAGE_TAB_TITLE_MAP.get(i)]); if (MAP_INDICATOR_DYNAMIC_VISIBILITY) { if (i == RMBTResultPagerAdapter.RESULT_PAGE_MAP) { indicator.setVisibility(View.GONE); } } tab.setIndicator(indicator); tabHost.addTab(tab); } scroller = (HorizontalScrollView) v.findViewById(R.id.tabwidget_scrollview); viewPager = (ExtendedViewPager) v.findViewById(R.id.pager); viewPager.setAdapter(pagerAdapter); viewPager.setOnPageChangeListener(this); setCurrentPosition(currentPage); return v; }
Example 7
Source File: DocActivityView.java From Mupdf with Apache License 2.0 | 5 votes |
protected void setupTabs() { tabHost = (TabHost) findViewById(R.id.tabhost); tabHost.setup(); // get the tab tags. mTagHidden = getResources().getString(R.string.hidden_tab); mTagFile = getResources().getString(R.string.file_tab); mTagAnnotate = getResources().getString(R.string.annotate_tab); mTagPages = getResources().getString(R.string.pages_tab); // first tab is and stays hidden. // when the search tab is selected, we programmatically "select" this hidden tab // which results in NO tabs appearing selected in this tab host. setupTab(tabHost, mTagHidden, R.id.hiddenTab, R.layout.tab); tabHost.getTabWidget().getChildTabViewAt(0).setVisibility(View.GONE); // these tabs are shown. setupTab(tabHost, mTagFile, R.id.fileTab, R.layout.tab_left); setupTab(tabHost, mTagAnnotate, R.id.annotateTab, R.layout.tab); setupTab(tabHost, mTagPages, R.id.pagesTab, R.layout.tab_right); // start by showing the edit tab tabHost.setCurrentTabByTag(mTagFile); tabHost.setOnTabChangedListener(this); }
Example 8
Source File: NotepadActivity.java From aedict with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.notepad); showRomaji = new ShowRomaji() { @Override protected void show(boolean romaji) { for (int i = 0; i < getCategoryCount(); i++) { final ListView lv = getListView(i); if (lv != null) { final ArrayAdapter<?> adapter = (ArrayAdapter<?>) lv.getAdapter(); adapter.notifyDataSetChanged(); } } } }; initializeListView((ListView) findViewById(android.R.id.list), 0); findViewById(R.id.btnNotepadSearch).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { MainActivity.launch(NotepadActivity.this, ((TextView)findViewById(R.id.editNotepadSearch)).getText().toString().trim()); } }); final TabHost tabs = getTabHost(); tabs.setup(); updateTabs(); processIntent(); }
Example 9
Source File: SlideTabsActivity.java From GPS2SMS with GNU General Public License v3.0 | 5 votes |
private void initialiseTabHost() { mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); SlideTabsActivity.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec(getString(R.string.tab_mycoords)).setIndicator(getString(R.string.tab_mycoords))); SlideTabsActivity.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec(getString(R.string.tab_mysms)).setIndicator(getString(R.string.tab_mysms))); SlideTabsActivity.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec(getString(R.string.tab_mysms_out)).setIndicator(getString(R.string.tab_mysms_out))); mTabHost.setOnTabChangedListener(this); }
Example 10
Source File: TabHostTestActivity.java From AutoTrackAppClick6 with Apache License 2.0 | 5 votes |
@SuppressWarnings("Convert2Lambda") private void initTabHost() { TabHost tabHost = findViewById(R.id.tabhost); tabHost.setup(); LayoutInflater.from(this).inflate(R.layout.tab1, tabHost.getTabContentView()); LayoutInflater.from(this).inflate(R.layout.tab2, tabHost.getTabContentView()); LayoutInflater.from(this).inflate(R.layout.tab3, tabHost.getTabContentView()); tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("标签页一").setContent(R.id.tab01)); tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("标签页二").setContent(R.id.tab02)); tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("标签页三").setContent(R.id.tab03)); //标签切换事件处理,setOnTabChangedListener tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override // tabId是newTabSpec第一个参数设置的tab页名,并不是layout里面的标识符id public void onTabChanged(String tabId) { if (tabId.equals("tab1")) { //第一个标签 Toast.makeText(TabHostTestActivity.this, "点击标签页一", Toast.LENGTH_SHORT).show(); } if (tabId.equals("tab2")) { //第二个标签 Toast.makeText(TabHostTestActivity.this, "点击标签页二", Toast.LENGTH_SHORT).show(); } if (tabId.equals("tab3")) { //第三个标签 Toast.makeText(TabHostTestActivity.this, "点击标签页三", Toast.LENGTH_SHORT).show(); } } }); }
Example 11
Source File: MainTabActivity.java From coolreader with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.tab_main); LocalActivityManager lam = new LocalActivityManager(this, true); lam.dispatchCreate(savedInstanceState); thMain = (TabHost)findViewById(android.R.id.tabhost); thMain.setup(lam); thMain.addTab(newTabSpec(TAB_BOOKSHELF, R.string.tab_bookshelf, R.drawable.tab_bookshelf, new Intent(this,BookshelfActivity.class))); thMain.addTab(newTabSpec(TAB_BOOKMARK, R.string.tab_bookmark, R.drawable.tab_bookmark, new Intent(this,BookmarkActivity.class))); thMain.addTab(newTabSpec(TAB_BOOK_ONLINE, R.string.tab_book_online, R.drawable.tab_book_online, new Intent(this,MainActivity.class))); rbtnBookshelf = (RadioButton)findViewById(R.id.radio_button0); rbtnbookmark = (RadioButton)findViewById(R.id.radio_button1); rbtnBookOnline = (RadioButton)findViewById(R.id.radio_button2); rbtnBookshelf.setOnCheckedChangeListener(this); rbtnbookmark.setOnCheckedChangeListener(this); rbtnBookOnline.setOnCheckedChangeListener(this); File file = new File("/mnt/sdcard/DotcoolReader"); if(!file.exists()){ file.mkdir(); } }
Example 12
Source File: InstallConfirmActivity.java From fdroidclient with GNU General Public License v3.0 | 4 votes |
private void startInstallConfirm() { View appSnippet = findViewById(R.id.app_snippet); TextView appName = (TextView) appSnippet.findViewById(R.id.app_name); ImageView appIcon = (ImageView) appSnippet.findViewById(R.id.app_icon); TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost); appName.setText(app.name); ImageLoader.getInstance().displayImage(app.getIconUrl(this), appIcon, Utils.getRepoAppDisplayImageOptions()); tabHost.setup(); ViewPager viewPager = (ViewPager) findViewById(R.id.pager); TabsAdapter adapter = new TabsAdapter(this, tabHost, viewPager); adapter.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String tabId) { } }); boolean permVisible = false; scrollView = null; okCanInstall = false; int msg = 0; AppSecurityPermissions perms = new AppSecurityPermissions(this, appDiff.apkPackageInfo); if (appDiff.installedApplicationInfo != null) { msg = (appDiff.installedApplicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0 ? R.string.install_confirm_update_system : R.string.install_confirm_update; scrollView = new CaffeinatedScrollView(this); scrollView.setFillViewport(true); final boolean newPermissionsFound = perms.getPermissionCount(AppSecurityPermissions.WHICH_NEW) > 0; if (newPermissionsFound) { permVisible = true; scrollView.addView(perms.getPermissionsView( AppSecurityPermissions.WHICH_NEW)); } else { throw new RuntimeException("This should not happen. No new permissions were found" + " but InstallConfirmActivity has been started!"); } adapter.addTab(tabHost.newTabSpec(TAB_ID_NEW).setIndicator( getText(R.string.newPerms)), scrollView); } else { findViewById(R.id.tabscontainer).setVisibility(View.GONE); findViewById(R.id.divider).setVisibility(View.VISIBLE); } final int n = perms.getPermissionCount(AppSecurityPermissions.WHICH_ALL); if (n > 0) { permVisible = true; LayoutInflater inflater = (LayoutInflater) getSystemService( Context.LAYOUT_INFLATER_SERVICE); View root = inflater.inflate(R.layout.permissions_list, null); if (scrollView == null) { scrollView = (CaffeinatedScrollView) root.findViewById(R.id.scrollview); } final ViewGroup permList = (ViewGroup) root.findViewById(R.id.permission_list); permList.addView(perms.getPermissionsView(AppSecurityPermissions.WHICH_ALL)); adapter.addTab(tabHost.newTabSpec(TAB_ID_ALL).setIndicator( getText(R.string.allPerms)), root); } if (!permVisible) { if (appDiff.installedApplicationInfo != null) { // This is an update to an application, but there are no // permissions at all. msg = (appDiff.installedApplicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0 ? R.string.install_confirm_update_system_no_perms : R.string.install_confirm_update_no_perms; } else { // This is a new application with no permissions. throw new RuntimeException("no permissions requested. This screen should not appear!"); } tabHost.setVisibility(View.GONE); findViewById(R.id.filler).setVisibility(View.VISIBLE); findViewById(R.id.divider).setVisibility(View.GONE); scrollView = null; } if (msg != 0) { ((TextView) findViewById(R.id.install_confirm)).setText(msg); } installConfirm.setVisibility(View.VISIBLE); okButton = (Button) findViewById(R.id.ok_button); cancelButton = (Button) findViewById(R.id.cancel_button); okButton.setOnClickListener(this); cancelButton.setOnClickListener(this); if (scrollView == null) { // There is nothing to scroll view, so the ok button is immediately // set to install. okButton.setText(R.string.menu_install); okCanInstall = true; } else { scrollView.setFullScrollAction(new Runnable() { @Override public void run() { okButton.setText(R.string.menu_install); okCanInstall = true; } }); } }
Example 13
Source File: QoSCategoryPagerFragment.java From open-rmbt with Apache License 2.0 | 4 votes |
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { if (savedInstanceState != null && savedInstanceState.containsKey(BUNDLE_QOS_RESULTS)) { try { setQoSResult(new QoSServerResultCollection(new JSONArray(savedInstanceState.getString(BUNDLE_QOS_RESULTS)))); setDetailType(DetailType.valueOf(savedInstanceState.getString(BUNDLE_DETAIL_TYPE))); } catch (JSONException e) { //e.printStackTrace(); } } //DetailType detailType = DetailType.valueOf(args.getString(ARG_DETAIL_TYPE)); pagerAdapter = new QoSCategoryPagerAdapter((RMBTMainActivity) getActivity(), handler, results); View v = inflater.inflate(R.layout.result_tabhost_pager, container, false); tabHost = (TabHost) v.findViewById(android.R.id.tabhost); tabHost.setup(); tabHost.setOnTabChangedListener(this); for (int i = 0; i < pagerAdapter.getCount(); i++) { TabSpec tab = tabHost.newTabSpec(String.valueOf(i)); //tab.setIndicator(getActivity().getResources().getStringArray(R.array.result_page_title)[i]); tab.setContent(android.R.id.tabcontent); View indicator = inflater.inflate(R.layout.tabhost_indicator, null); TextView title = (TextView) indicator.findViewById(android.R.id.title); title.setText(pagerAdapter.getPageTitle(i)); tab.setIndicator(indicator); tabHost.addTab(tab); } viewPager = (ExtendedViewPager) v.findViewById(R.id.pager); viewPager.setAdapter(pagerAdapter); viewPager.setOnPageChangeListener(this); setCurrentPosition(0); scroller = (HorizontalScrollView) v.findViewById(R.id.tabwidget_scrollview); if (initPosition != null) { viewPager.setCurrentItem(initPosition); } return v; }
Example 14
Source File: DisplayAlternativeNovelPagerActivity.java From coolreader with MIT License | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { UIHelper.SetTheme(this, R.layout.activity_display_novel_pager); UIHelper.SetActionBarDisplayHomeAsUp(this, true); setContentView(R.layout.activity_display_novel_pager); } else { UIHelper.SetTheme(this, R.layout.activity_display_novel_pager_fix); UIHelper.SetActionBarDisplayHomeAsUp(this, true); setContentView(R.layout.activity_display_novel_pager_fix); } tabHost = (TabHost) findViewById(android.R.id.tabhost); lam = new LocalActivityManager(this, false); lam.dispatchCreate(savedInstanceState); tabHost.setup(lam); isInverted = UIHelper.getColorPreferences(this); tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { public void onTabChanged(String tabId) { setTabColor(); currentActivity = lam.getActivity(tabId); } }); /* Dynamically add Tabs */ ArrayList<String> Choice = new ArrayList<String>(); Iterator<Entry<String, AlternativeLanguageInfo>> it = AlternativeLanguageInfo.getAlternativeLanguageInfo().entrySet().iterator(); while (it.hasNext()) { AlternativeLanguageInfo info = it.next().getValue(); boolean isChosen = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(info.getLanguage(), true); if (isChosen) { Choice.add(info.getLanguage()); Log.d("Language Added: ", info.getLanguage()); } it.remove(); } TabSpec[] allSpec = new TabSpec[Choice.size()]; for (int i = 0; i < Choice.size(); i++) { allSpec[i] = tabHost.newTabSpec(Choice.get(i)); allSpec[i].setIndicator(Choice.get(i)); Intent firstIntent = new Intent(this, DisplayAlternativeNovelListActivity.class); firstIntent.putExtra("LANG", Choice.get(i)); allSpec[i].setContent(firstIntent); // Adding all TabSpec to TabHost tabHost.addTab(allSpec[i]); // Cheap preload list hack. tabHost.setCurrentTabByTag(Choice.get(i)); } // Tab color setTabColor(); }
Example 15
Source File: DisplayNovelPagerActivity.java From coolreader with MIT License | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { UIHelper.SetTheme(this, R.layout.activity_display_novel_pager); UIHelper.SetActionBarDisplayHomeAsUp(this, true); setContentView(R.layout.activity_display_novel_pager); } else { UIHelper.SetTheme(this, R.layout.activity_display_novel_pager_fix); UIHelper.SetActionBarDisplayHomeAsUp(this, true); setContentView(R.layout.activity_display_novel_pager_fix); } tabHost = (TabHost) findViewById(android.R.id.tabhost); lam = new LocalActivityManager(this, false); lam.dispatchCreate(savedInstanceState); tabHost.setup(lam); isInverted = UIHelper.getColorPreferences(this); // First Tab - Normal Novels TabSpec firstSpec = tabHost.newTabSpec(MAIN_SPEC); firstSpec.setIndicator(MAIN_SPEC); Intent firstIntent = new Intent(this, DisplayLightNovelListActivity.class); firstIntent.putExtra(Constants.EXTRA_ONLY_WATCHED, false); firstSpec.setContent(firstIntent); // Second Tab - Teasers TabSpec secondSpec = tabHost.newTabSpec(TEASER_SPEC); secondSpec.setIndicator(TEASER_SPEC); Intent secondIntent = new Intent(this, DisplayTeaserListActivity.class); secondSpec.setContent(secondIntent); // Third Tab - Original TabSpec thirdSpec = tabHost.newTabSpec(ORIGINAL_SPEC); thirdSpec.setIndicator(ORIGINAL_SPEC); Intent thirdIntent = new Intent(this, DisplayOriginalListActivity.class); thirdSpec.setContent(thirdIntent); // Adding all TabSpec to TabHost tabHost.addTab(firstSpec); // Adding First tab tabHost.addTab(secondSpec); // Adding Second tab tabHost.addTab(thirdSpec); // Adding third tab //setTabColor(); tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { public void onTabChanged(String tabId) { //setTabColor(); currentActivity = lam.getActivity(tabId); } }); // Cheap preload list hack. tabHost.setCurrentTabByTag(TEASER_SPEC); tabHost.setCurrentTabByTag(ORIGINAL_SPEC); tabHost.setCurrentTabByTag(MAIN_SPEC); Log.d(TAG, "Created"); }
Example 16
Source File: EmojiPalettesView.java From Indic-Keyboard with Apache License 2.0 | 4 votes |
@Override protected void onFinishInflate() { mTabHost = (TabHost)findViewById(R.id.emoji_category_tabhost); mTabHost.setup(); for (final EmojiCategory.CategoryProperties properties : mEmojiCategory.getShownCategories()) { addTab(mTabHost, properties.mCategoryId); } mTabHost.setOnTabChangedListener(this); final TabWidget tabWidget = mTabHost.getTabWidget(); tabWidget.setStripEnabled(mCategoryIndicatorEnabled); if (mCategoryIndicatorEnabled) { // On TabWidget's strip, what looks like an indicator is actually a background. // And what looks like a background are actually left and right drawables. tabWidget.setBackgroundResource(mCategoryIndicatorDrawableResId); tabWidget.setLeftStripDrawable(mCategoryIndicatorBackgroundResId); tabWidget.setRightStripDrawable(mCategoryIndicatorBackgroundResId); } mEmojiPalettesAdapter = new EmojiPalettesAdapter(mEmojiCategory, this); mEmojiPager = (ViewPager)findViewById(R.id.emoji_keyboard_pager); mEmojiPager.setAdapter(mEmojiPalettesAdapter); mEmojiPager.setOnPageChangeListener(this); mEmojiPager.setOffscreenPageLimit(0); mEmojiPager.setPersistentDrawingCache(PERSISTENT_NO_CACHE); mEmojiLayoutParams.setPagerProperties(mEmojiPager); mEmojiCategoryPageIndicatorView = (EmojiCategoryPageIndicatorView)findViewById(R.id.emoji_category_page_id_view); mEmojiCategoryPageIndicatorView.setColors( mCategoryPageIndicatorColor, mCategoryPageIndicatorBackground); mEmojiLayoutParams.setCategoryPageIdViewProperties(mEmojiCategoryPageIndicatorView); setCurrentCategoryId(mEmojiCategory.getCurrentCategoryId(), true /* force */); final LinearLayout actionBar = (LinearLayout)findViewById(R.id.emoji_action_bar); mEmojiLayoutParams.setActionBarProperties(actionBar); // deleteKey depends only on OnTouchListener. mDeleteKey = (ImageButton)findViewById(R.id.emoji_keyboard_delete); mDeleteKey.setBackgroundResource(mFunctionalKeyBackgroundId); mDeleteKey.setTag(Constants.CODE_DELETE); mDeleteKey.setOnTouchListener(mDeleteKeyOnTouchListener); // {@link #mAlphabetKeyLeft}, {@link #mAlphabetKeyRight, and spaceKey depend on // {@link View.OnClickListener} as well as {@link View.OnTouchListener}. // {@link View.OnTouchListener} is used as the trigger of key-press, while // {@link View.OnClickListener} is used as the trigger of key-release which does not occur // if the event is canceled by moving off the finger from the view. // The text on alphabet keys are set at // {@link #startEmojiPalettes(String,int,float,Typeface)}. mAlphabetKeyLeft = (TextView)findViewById(R.id.emoji_keyboard_alphabet_left); mAlphabetKeyLeft.setBackgroundResource(mFunctionalKeyBackgroundId); mAlphabetKeyLeft.setTag(Constants.CODE_ALPHA_FROM_EMOJI); mAlphabetKeyLeft.setOnTouchListener(this); mAlphabetKeyLeft.setOnClickListener(this); mAlphabetKeyRight = (TextView)findViewById(R.id.emoji_keyboard_alphabet_right); mAlphabetKeyRight.setBackgroundResource(mFunctionalKeyBackgroundId); mAlphabetKeyRight.setTag(Constants.CODE_ALPHA_FROM_EMOJI); mAlphabetKeyRight.setOnTouchListener(this); mAlphabetKeyRight.setOnClickListener(this); mSpacebar = findViewById(R.id.emoji_keyboard_space); mSpacebar.setBackgroundResource(mSpacebarBackgroundId); mSpacebar.setTag(Constants.CODE_SPACE); mSpacebar.setOnTouchListener(this); mSpacebar.setOnClickListener(this); mEmojiLayoutParams.setKeyProperties(mSpacebar); mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon); }
Example 17
Source File: WaypointProperties.java From Androzic with GNU General Public License v3.0 | 4 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Androzic application = Androzic.getApplication(); View rootView = inflater.inflate(R.layout.act_waypoint_properties, container, false); tabHost = (TabHost) rootView.findViewById(R.id.tabhost); tabHost.setup(); tabHost.addTab(tabHost.newTabSpec("main").setIndicator(getString(R.string.primary)).setContent(R.id.properties)); tabHost.addTab(tabHost.newTabSpec("advanced").setIndicator(getString(R.string.advanced)).setContent(R.id.advanced)); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = 50; tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = 50; } name = (TextView) rootView.findViewById(R.id.name_text); description = (TextView) rootView.findViewById(R.id.description_text); altitude = (TextView) rootView.findViewById(R.id.altitude_text); proximity = (TextView) rootView.findViewById(R.id.proximity_text); iconValue = null; ImageButton icon = (ImageButton) rootView.findViewById(R.id.icon_button); icon.setImageDrawable(getResources().getDrawable(R.drawable.ic_highlight_remove_white_24dp)); if (waypoint.drawImage) { Bitmap b = BitmapFactory.decodeFile(application.markerPath + File.separator + waypoint.marker); if (b != null) { icon.setImageBitmap(b); iconValue = waypoint.marker; } } icon.setOnClickListener(iconOnClickListener); ArrayList<String> items = new ArrayList<String>(); for (WaypointSet wptset : application.getWaypointSets()) { items.add(wptset.name); } waypointSet = (Spinner) rootView.findViewById(R.id.set_spinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, items); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); waypointSet.setAdapter(adapter); markercolor = (ColorButton) rootView.findViewById(R.id.markercolor_button); textcolor = (ColorButton) rootView.findViewById(R.id.textcolor_button); coordDeg = (ViewGroup) rootView.findViewById(R.id.coord_deg); coordUtm = (ViewGroup) rootView.findViewById(R.id.coord_utm); coordMgrs = (ViewGroup) rootView.findViewById(R.id.coord_mgrs); coordLatDeg = (ViewGroup) rootView.findViewById(R.id.coord_lat_deg); coordLatMin = (ViewGroup) rootView.findViewById(R.id.coord_lat_min); coordLatSec = (ViewGroup) rootView.findViewById(R.id.coord_lat_sec); coordLonDeg = (ViewGroup) rootView.findViewById(R.id.coord_lon_deg); coordLonMin = (ViewGroup) rootView.findViewById(R.id.coord_lon_min); coordLonSec = (ViewGroup) rootView.findViewById(R.id.coord_lon_sec); Spinner coordformat = (Spinner) rootView.findViewById(R.id.coordformat_spinner); coordformat.setOnItemSelectedListener(this); coordformat.setSelection(StringFormatter.coordinateFormat); return rootView; }
Example 18
Source File: WizardActivity.java From CameraV with GNU General Public License v3.0 | 4 votes |
public void initLayout() { pager = new TabPager(getSupportFragmentManager()); tabHost = (TabHost) findViewById(android.R.id.tabhost); tabHost.setup(); tabHost.setOnTabChangedListener(pager); viewPager.setAdapter(pager); viewPager.setOnPageChangeListener(pager); viewPager.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); TabHost.TabSpec tabSpec = null; @SuppressWarnings("unused") View indicator = null; int i = 1; for(Fragment f : fragments) { tabSpec = tabHost.newTabSpec(f.getClass().getSimpleName()) .setIndicator(indicator = new Indicator(String.valueOf(i), this).tab) .setContent(new TabHost.TabContentFactory() { @Override public View createTabContent(String tag) { View view = new View(WizardActivity.this); view.setMinimumHeight(0); view.setMinimumWidth(0); return view; } }); tabHost.addTab(tabSpec); i++; } if(getIntent().hasExtra(Codes.Extras.CHANGE_LOCALE)) { getIntent().removeExtra(Codes.Extras.CHANGE_LOCALE); viewPager.setCurrentItem(1); } }
Example 19
Source File: TrackDetailActivity.java From mytracks with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); hasCamera = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA); photoUri = savedInstanceState != null ? (Uri) savedInstanceState.getParcelable(PHOTO_URI_KEY) : null; hasPhoto = savedInstanceState != null ? savedInstanceState.getBoolean(HAS_PHOTO_KEY, false) : false; myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this); handleIntent(getIntent()); sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE); trackRecordingServiceConnection = new TrackRecordingServiceConnection( this, bindChangedCallback); trackDataHub = TrackDataHub.newInstance(this); tabHost = (TabHost) findViewById(android.R.id.tabhost); tabHost.setup(); viewPager = (ViewPager) findViewById(R.id.pager); tabsAdapter = new TabsAdapter(this, tabHost, viewPager); TabSpec mapTabSpec = tabHost.newTabSpec(MyTracksMapFragment.MAP_FRAGMENT_TAG).setIndicator( getString(R.string.track_detail_map_tab), getResources().getDrawable(R.drawable.ic_tab_map)); tabsAdapter.addTab(mapTabSpec, MyTracksMapFragment.class, null); TabSpec chartTabSpec = tabHost.newTabSpec(ChartFragment.CHART_FRAGMENT_TAG).setIndicator( getString(R.string.track_detail_chart_tab), getResources().getDrawable(R.drawable.ic_tab_chart)); tabsAdapter.addTab(chartTabSpec, ChartFragment.class, null); TabSpec statsTabSpec = tabHost.newTabSpec(StatsFragment.STATS_FRAGMENT_TAG).setIndicator( getString(R.string.track_detail_stats_tab), getResources().getDrawable(R.drawable.ic_tab_stats)); tabsAdapter.addTab(statsTabSpec, StatsFragment.class, null); if (savedInstanceState != null) { tabHost.setCurrentTabByTag(savedInstanceState.getString(CURRENT_TAB_TAG_KEY)); } // Set the background after all three tabs are added ApiAdapterFactory.getApiAdapter().setTabBackground(tabHost.getTabWidget()); trackController = new TrackController( this, trackRecordingServiceConnection, false, recordListener, stopListener); }
Example 20
Source File: EmojiPalettesView.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 4 votes |
@Override protected void onFinishInflate() { mTabHost = (TabHost)findViewById(R.id.emoji_category_tabhost); mTabHost.setup(); for (final EmojiCategory.CategoryProperties properties : mEmojiCategory.getShownCategories()) { addTab(mTabHost, properties.mCategoryId); } mTabHost.setOnTabChangedListener(this); final TabWidget tabWidget = mTabHost.getTabWidget(); tabWidget.setStripEnabled(mCategoryIndicatorEnabled); if (mCategoryIndicatorEnabled) { // On TabWidget's strip, what looks like an indicator is actually a background. // And what looks like a background are actually left and right drawables. tabWidget.setBackgroundResource(mCategoryIndicatorDrawableResId); tabWidget.setLeftStripDrawable(mCategoryIndicatorBackgroundResId); tabWidget.setRightStripDrawable(mCategoryIndicatorBackgroundResId); } mEmojiPalettesAdapter = new EmojiPalettesAdapter(mEmojiCategory, this); mEmojiPager = (ViewPager)findViewById(R.id.emoji_keyboard_pager); mEmojiPager.setAdapter(mEmojiPalettesAdapter); mEmojiPager.setOnPageChangeListener(this); mEmojiPager.setOffscreenPageLimit(0); mEmojiPager.setPersistentDrawingCache(PERSISTENT_NO_CACHE); mEmojiLayoutParams.setPagerProperties(mEmojiPager); mEmojiCategoryPageIndicatorView = (EmojiCategoryPageIndicatorView)findViewById(R.id.emoji_category_page_id_view); mEmojiCategoryPageIndicatorView.setColors( mCategoryPageIndicatorColor, mCategoryPageIndicatorBackground); mEmojiLayoutParams.setCategoryPageIdViewProperties(mEmojiCategoryPageIndicatorView); setCurrentCategoryId(mEmojiCategory.getCurrentCategoryId(), true /* force */); final LinearLayout actionBar = (LinearLayout)findViewById(R.id.emoji_action_bar); mEmojiLayoutParams.setActionBarProperties(actionBar); // deleteKey depends only on OnTouchListener. mDeleteKey = (ImageButton)findViewById(R.id.emoji_keyboard_delete); mDeleteKey.setBackgroundResource(mFunctionalKeyBackgroundId); mDeleteKey.setTag(Constants.CODE_DELETE); mDeleteKey.setOnTouchListener(mDeleteKeyOnTouchListener); // {@link #mAlphabetKeyLeft}, {@link #mAlphabetKeyRight, and spaceKey depend on // {@link View.OnClickListener} as well as {@link View.OnTouchListener}. // {@link View.OnTouchListener} is used as the trigger of key-press, while // {@link View.OnClickListener} is used as the trigger of key-release which does not occur // if the event is canceled by moving off the finger from the view. // The text on alphabet keys are set at // {@link #startEmojiPalettes(String,int,float,Typeface)}. mAlphabetKeyLeft = (TextView)findViewById(R.id.emoji_keyboard_alphabet_left); mAlphabetKeyLeft.setBackgroundResource(mFunctionalKeyBackgroundId); mAlphabetKeyLeft.setTag(Constants.CODE_ALPHA_FROM_EMOJI); mAlphabetKeyLeft.setOnTouchListener(this); mAlphabetKeyLeft.setOnClickListener(this); mAlphabetKeyRight = (TextView)findViewById(R.id.emoji_keyboard_alphabet_right); mAlphabetKeyRight.setBackgroundResource(mFunctionalKeyBackgroundId); mAlphabetKeyRight.setTag(Constants.CODE_ALPHA_FROM_EMOJI); mAlphabetKeyRight.setOnTouchListener(this); mAlphabetKeyRight.setOnClickListener(this); mSpacebar = findViewById(R.id.emoji_keyboard_space); mSpacebar.setBackgroundResource(mSpacebarBackgroundId); mSpacebar.setTag(Constants.CODE_SPACE); mSpacebar.setOnTouchListener(this); mSpacebar.setOnClickListener(this); mEmojiLayoutParams.setKeyProperties(mSpacebar); mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon); }