List of usage examples for android.app ActionBar newTab
@Deprecated public abstract Tab newTab();
From source file:net.sakuramilk.kbcupdater.MainFragmentActivity.java
/** Called when the activity is first created. */ @Override/*from ww w . j av a 2 s.c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.viewpager); setContentView(mViewPager); final ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); bar.setTitle(R.string.app_name); mPagerAdapter = new TabsFragmentAdapter(this, mViewPager); Bundle args = new Bundle(); args.putString("url", Constant.LIST_URL_SC06D); mPagerAdapter.addTab(bar.newTab().setText("SC-06D"), DeviceFragmentActivity.class, args); /* args = new Bundle(); args.putString("url", "https://github.com/kbc-developers/release/wiki/sc04d"); mPagerAdapter.addTab(bar.newTab().setText("SC-04D"), DeviceFragmentActivity.class, args); */ args = new Bundle(); args.putString("url", Constant.LIST_URL_SC02C); mPagerAdapter.addTab(bar.newTab().setText("SC-02C"), DeviceFragmentActivity.class, args); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0)); } }
From source file:com.aniruddhc.acemusic.player.PlaylistEditorActivity.PlaylistEditorActivity.java
@Override public void onCreate(Bundle savedInstanceState) { //Initialize Context and SharedPreferences. mContext = this; mApp = (Common) this.getApplicationContext(); sharedPreferences = mContext.getSharedPreferences("com.aniruddhc.acemusic.player", Context.MODE_PRIVATE); //Set the UI theme. if (mApp.getCurrentTheme() == Common.DARK_THEME) { setTheme(R.style.AppTheme);/* w w w . j a v a2 s . co m*/ } else { setTheme(R.style.AppThemeLight); } super.onCreate(savedInstanceState); //Create a set of options to optimize the bitmap memory usage. final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; options.inJustDecodeBounds = false; options.inPurgeable = true; //Display Image Options. displayImageOptions = new DisplayImageOptions.Builder().showImageForEmptyUri(R.drawable.default_album_art) .showImageOnFail(R.drawable.default_album_art).showStubImage(R.drawable.transparent_drawable) .cacheInMemory(false).cacheOnDisc(true).decodingOptions(options) .imageScaleType(ImageScaleType.EXACTLY).bitmapConfig(Bitmap.Config.RGB_565) .displayer(new FadeInBitmapDisplayer(400)).delayBeforeLoading(100).build(); //Attach tabs to the ActionBar. ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); //Add the artists tab. String artistsLabel = getResources().getString(R.string.artists); Tab tab = actionBar.newTab(); tab.setText(artistsLabel); TabListener<ArtistsPickerFragment> artistsTabListener = new TabListener<ArtistsPickerFragment>(this, artistsLabel, ArtistsPickerFragment.class); tab.setTabListener(artistsTabListener); actionBar.addTab(tab); //Add the albums tab. String albumsLabel = getResources().getString(R.string.albums); tab = actionBar.newTab(); tab.setText(albumsLabel); TabListener<AlbumsPickerFragment> albumsTabListener = new TabListener<AlbumsPickerFragment>(this, albumsLabel, AlbumsPickerFragment.class); tab.setTabListener(albumsTabListener); actionBar.addTab(tab); //Add the songs tab. String songsLabel = getResources().getString(R.string.songs); tab = actionBar.newTab(); tab.setText(songsLabel); TabListener<SongsPickerFragment> songsTabListener = new TabListener<SongsPickerFragment>(this, songsLabel, SongsPickerFragment.class); tab.setTabListener(songsTabListener); actionBar.addTab(tab); }
From source file:com.Duo.music.player.PlaylistEditorActivity.PlaylistEditorActivity.java
@Override public void onCreate(Bundle savedInstanceState) { //Initialize Context and SharedPreferences. mContext = this; mApp = (Common) this.getApplicationContext(); sharedPreferences = mContext.getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE); //Set the UI theme. if (mApp.getCurrentTheme() == Common.DARK_THEME) { setTheme(R.style.AppTheme);/*from w w w. j a v a 2 s . c o m*/ } else { setTheme(R.style.AppThemeLight); } super.onCreate(savedInstanceState); //Create a set of options to optimize the bitmap memory usage. final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; options.inJustDecodeBounds = false; options.inPurgeable = true; //Display Image Options. displayImageOptions = new DisplayImageOptions.Builder().showImageForEmptyUri(R.drawable.default_album_art) .showImageOnFail(R.drawable.default_album_art).showStubImage(R.drawable.transparent_drawable) .cacheInMemory(false).cacheOnDisc(true).decodingOptions(options) .imageScaleType(ImageScaleType.EXACTLY).bitmapConfig(Bitmap.Config.RGB_565) .displayer(new FadeInBitmapDisplayer(400)).delayBeforeLoading(100).build(); //Attach tabs to the ActionBar. ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); //Add the artists tab. String artistsLabel = getResources().getString(R.string.artists); Tab tab = actionBar.newTab(); tab.setText(artistsLabel); TabListener<ArtistsPickerFragment> artistsTabListener = new TabListener<ArtistsPickerFragment>(this, artistsLabel, ArtistsPickerFragment.class); tab.setTabListener(artistsTabListener); actionBar.addTab(tab); //Add the albums tab. String albumsLabel = getResources().getString(R.string.albums); tab = actionBar.newTab(); tab.setText(albumsLabel); TabListener<AlbumsPickerFragment> albumsTabListener = new TabListener<AlbumsPickerFragment>(this, albumsLabel, AlbumsPickerFragment.class); tab.setTabListener(albumsTabListener); actionBar.addTab(tab); //Add the songs tab. String songsLabel = getResources().getString(R.string.songs); tab = actionBar.newTab(); tab.setText(songsLabel); TabListener<SongsPickerFragment> songsTabListener = new TabListener<SongsPickerFragment>(this, songsLabel, SongsPickerFragment.class); tab.setTabListener(songsTabListener); actionBar.addTab(tab); }
From source file:com.example.routerecorder.FragmentTabs.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); instance = this; final ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); //bar.setDisplayShowCustomEnabled(true); //bar.setDisplayShowTitleEnabled(false); //bar.setDisplayShowHomeEnabled(false); bar.setDisplayShowCustomEnabled(false); bar.addTab(bar.newTab().setText("Show Map") .setTabListener(new TabListener<RouteMapFragment>(this, "Show Map", RouteMapFragment.class))); bar.addTab(bar.newTab().setText("Add Trip") .setTabListener(new TabListener<AddRouteFragment>(this, "Add Trip", AddRouteFragment.class))); bar.addTab(bar.newTab().setText("Show List") .setTabListener(new TabListener<MyListFragment>(this, "Show List", MyListFragment.class))); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0)); }/*from w w w.j a v a2s . c om*/ //FragmentManager manager = getSupportFragmentManager(); //fragmentA = (RouteMapFragment) manager.findFragmentById(R.id.map); //fragmentB = (AddRouteFragment) manager.findFragmentById(R.id.fragment_container); }
From source file:com.yuya.routerecorder.FragmentTabs.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); instance = this; final ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); //bar.setDisplayShowCustomEnabled(true); //bar.setDisplayShowTitleEnabled(false); //bar.setDisplayShowHomeEnabled(false); bar.setDisplayShowCustomEnabled(false); bar.addTab(bar.newTab().setIcon(R.drawable.world_white) .setTabListener(new TabListener<RouteMapFragment>(this, "Show Map", RouteMapFragment.class))); bar.addTab(bar.newTab().setIcon(R.drawable.pen_white_frame) .setTabListener(new TabListener<AddRouteFragment>(this, "Add Trip", AddRouteFragment.class))); bar.addTab(bar.newTab().setIcon(R.drawable.list_new) .setTabListener(new TabListener<MyListFragment>(this, "Show List", MyListFragment.class))); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0)); }//w ww . ja v a2 s. c om //FragmentManager manager = getSupportFragmentManager(); //fragmentA = (RouteMapFragment) manager.findFragmentById(R.id.map); //fragmentB = (AddRouteFragment) manager.findFragmentById(R.id.fragment_container); }
From source file:com.aogp.about.AboutActivity.java
/** Called when the activity is first created. */ @Override//from www. j a va 2s . c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); appContext = getApplicationContext(); ActionBar actionbar = getActionBar(); actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionbar.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.about_tab_title), AboutFragment.class, null); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.features_tab_title), FeaturesFragment.class, null); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.aogp_tab_title), AOGPFragment.class, null); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.contributors_tab_title), ContributorsFragment.class, null); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.testers_tab_title), TestersFragment.class, null); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.social_tab_title), SocialFragment.class, null); }
From source file:com.plnyyanks.frcnotebook.activities.ViewEvent.java
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(PreferenceHandler.getTheme()); super.onCreate(savedInstanceState); setContentView(R.layout.activity_view_event); activity = this; if (event == null) { Intent intent = new Intent(this, StartActivity.class); startActivity(intent);//from ww w.j a v a 2s.c o m return; } ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setTitle(event.getEventName()); bar.setSubtitle("#" + key); bar.setDisplayHomeAsUpEnabled(true); //tab for team list ActionBar.Tab teamListTab = bar.newTab(); teamListTab.setText("Teams Attending"); teamListTab.setTabListener(this); bar.addTab(teamListTab); //tab for match schedule ActionBar.Tab scheduleTab = bar.newTab(); scheduleTab.setText("Match Schedule"); scheduleTab.setTabListener(this); bar.addTab(scheduleTab); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_NAVIGATION_ITEM, 0)); } else { bar.setSelectedNavigationItem(0); } }
From source file:com.yohpapa.overlaymusicplayer.activity.MainActivity.java
private void setupActionBar() { ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayShowHomeEnabled(false); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); int lastPosition = PrefUtils.getInt(this, R.string.pref_last_tab_position, 0); for (int i = 0; i < fragmentNames.length; i++) { ActionBar.Tab tab = bar.newTab(); tab.setText(fragmentNames[i]);/*from www . j ava2 s . c om*/ tab.setTabListener(new ActionBar.TabListener() { @Override public void onTabUnselected(Tab tab, FragmentTransaction ft) { Log.d(TAG, "onTabUnselected"); } @Override public void onTabSelected(Tab tab, FragmentTransaction ft) { ViewPager pager = (ViewPager) findViewById(R.id.fragment_pager); pager.setCurrentItem(tab.getPosition()); PrefUtils.setInt(MainActivity.this, R.string.pref_last_tab_position, tab.getPosition()); } @Override public void onTabReselected(Tab tab, FragmentTransaction ft) { Fragment fragment = fragments[tab.getPosition()]; if (fragment instanceof CommonListFragment) { ((CommonListFragment) fragment).onTapWhenSelected(); } } }); boolean isSelected = false; if (i == lastPosition) { isSelected = true; } bar.addTab(tab, isSelected); } }
From source file:com.hybris.mobile.activity.LoginActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); mViewPager = (ViewPager) findViewById(R.id.pager); Fragment[] frags = { new LoginFragment(), new RegistrationFragment() }; FragmentPagerAdapter adapter = new TabsAdapter(getFragmentManager(), frags); mViewPager.setAdapter(adapter);/*from w w w.ja v a 2 s .com*/ mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { getActionBar().setSelectedNavigationItem(position); } }); ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); MyTabListener tabListener = new MyTabListener(mViewPager, actionBar); Tab tab = actionBar.newTab().setText(R.string.tab_login).setTabListener(tabListener); actionBar.addTab(tab); tab = actionBar.newTab().setText(R.string.tab_register).setTabListener(tabListener); actionBar.addTab(tab); actionBar.setSelectedNavigationItem(0); // Handler to handle different asynchronous cases: // - When the user arrives from the scanning activity and scan a barcode that needs the user to be logged in, mHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { // Error retrieving the data of the scanned value, we finish the activity and display a error message case BarCodeScannerActivity.MSG_DATA_ERROR: showMessage((String) msg.obj); finish(); break; // Data available, we can start the activity associated with the intent case BarCodeScannerActivity.MSG_DATA_AVAILABLE: if (mIntentBarcodeAfterLogin != null) { mIntentBarcodeAfterLogin.startActivity(); finish(); } break; } } }; }
From source file:scmu.nutweet.bluetooth.BluetoothChat.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (D)/*from w w w . ja va 2 s . c om*/ Log.e(TAG, "+++ ON CREATE +++"); // Set up the window layout setContentView(R.layout.activity_chat); // Set up the action bar to show tabs. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayHomeAsUpEnabled(true); // For each of the sections in the app, add a tab to the action bar. actionBar.addTab(actionBar.newTab().setIcon(R.drawable.friends_black).setTabListener(this)); actionBar.addTab(actionBar.newTab().setIcon(R.drawable.chatmsg_black).setTabListener(this)); //stateChange(Const.mService.getState()); }