List of usage examples for android.app ActionBar setNavigationMode
@Deprecated public abstract void setNavigationMode(@NavigationMode int mode);
From source file:com.example.android.foodstorm.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); dataSource = new FoodSQLiteHelper(this); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(false); // no home/up button actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override//from w w w.j av a 2 s .co m public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); actionBar.addTab(actionBar.newTab().setIcon(R.drawable.fridge_main).setTabListener(this)); actionBar.addTab(actionBar.newTab().setIcon(R.drawable.chef_hat).setTabListener(this)); }
From source file:com.patil.geobells.lite.MainActivity.java
public void restoreActionBar() { ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(title);/*from w w w . java 2s. co m*/ }
From source file:com.tesfayeabel.lolchat.ui.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_lolchat_main); viewPager = (ViewPager) findViewById(R.id.pager); final ActionBar actionBar = getActionBar(); ArrayList<LOLChatFragment> fragments = new ArrayList<LOLChatFragment>(); fragments.add(new MainFragment()); fragments.add(new ConversationsFragment()); fragments.add(new SummonerSearchFragment()); viewPager.setOffscreenPageLimit(fragments.size() - 1); viewPager.setAdapter(new FragmentPagerAdapter(getFragmentManager(), fragments)); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override/*from www .j a va 2 s. c o m*/ public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); FragmentPagerAdapter adapter = (FragmentPagerAdapter) viewPager.getAdapter(); if (getLolChat() != null) adapter.getRegisteredFragment(position).onChatConnected(getLolChat()); } @Override public void onPageScrolled(int i, float f, int f1) { } @Override public void onPageScrollStateChanged(int i) { } }); ActionBar.TabListener tl = new ActionBar.TabListener() { @Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { viewPager.setCurrentItem(tab.getPosition()); } @Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { } @Override public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { } }; actionBar.addTab(actionBar.newTab().setIcon(R.drawable.lolchat_friend).setTabListener(tl)); actionBar.addTab(actionBar.newTab().setIcon(R.drawable.lolchat_recent).setTabListener(tl)); actionBar.addTab(actionBar.newTab().setIcon(R.drawable.lolchat_search).setTabListener(tl)); }
From source file:com.example.kaow.caltest.UserInfo.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_user_info); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); final ActionBar actionBar = getActionBar(); // Specify that the Home button should show an "Up" caret, indicating that touching the // button will take the user one step up in the application's hierarchy. actionBar.setDisplayHomeAsUpEnabled(true); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override// w w w .j a va2s . c o m public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < uInfoTitles.length; i++) { actionBar.addTab(actionBar.newTab().setText(uInfoTitles[i]).setTabListener(this)); } }
From source file:com.dvdprime.mobile.android.ui.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Create the adapter that will return a fragment for each of the three primary sections of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical parent. actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener for when the user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override// www .ja va 2 s . c o m public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the Tab. actionBar.setSelectedNavigationItem(position); EasyTracker.getTracker().sendView(AppSectionsPagerAdapter.tabEngTitles[position]); LOGD("Tracker", AppSectionsPagerAdapter.tabEngTitles[position]); // Save position value in preference PrefUtil.getInstance().setInt(PrefKeys.LAST_TAB_POSITION, position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by the adapter. // Also specify this Activity object, which implements the TabListener interface, as the listener for when this tab is selected. actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } // Google Analytics EasyTracker.getInstance().setContext(this); EasyTracker.getTracker().sendView("Main"); LOGD("Tracker", "Main"); // Set Last Tab lastPosition = PrefUtil.getInstance().getInt(PrefKeys.LAST_TAB_POSITION, 0); actionBar.setSelectedNavigationItem(lastPosition); // . if (PrefUtil.getInstance().getString(PrefKeys.ACCOUNT_ID, null) != null) { JsonObjectRequest filterReq = new JsonObjectRequest( StringUtil.format(Config.MOBILE_DP_COUNT, PrefUtil.getInstance().getString(PrefKeys.ACCOUNT_ID, null)), null, createJsonReqSuccessListener(), createJsonReqErrorListener()); filterReq.setTag(TAG); DpApp.getRequestQueue().add(filterReq); } // ? if (SystemUtil.getVersionName(this).equals("1.0") && PrefUtil.getInstance().getBoolean(PrefKeys.VERSION_1_0, true)) { String msg = new StringBuffer().append("[1.0 ]\n\n").append( "-? \n ? ?? ? ? ?? /?.\n\n") .append("- \n ? ? ?. ? ? ?.") .toString(); new AlertDialog.Builder(this).setTitle(getString(R.string.alert_dialog_version)).setMessage(msg) .setCancelable(false) .setPositiveButton(getString(R.string.alert_dialog_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { PrefUtil.getInstance().setBoolean(PrefKeys.VERSION_1_0, false); dialog.dismiss(); } }).create().show(); } }
From source file:com.glanznig.beepme.view.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//from w w w. j a v a 2s .com audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); pagerAdapter = new MainSectionsPagerAdapter(getSupportFragmentManager(), this); final ActionBar actionBar = getActionBar(); final BeeperApp app = (BeeperApp) getApplication(); if (app.getPreferences().isTestMode()) { actionBar.setSubtitle(getString(R.string.pref_title_test_mode)); } // displaying tabs in the action bar actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); pager = (ViewPager) findViewById(R.id.main_tab_pager); pager.setAdapter(pagerAdapter); // set gap between pages pager.setPageMargin((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, this.getResources().getDisplayMetrics())); pager.setPageMarginDrawable(R.drawable.swipe_filler); // listening for page changes pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); // for each of the sections in the app, add a tab to the action bar for (int i = 0; i < pagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by the adapter. // Also specify this Activity object, which implements the TabListener interface, as the // listener for when this tab is selected. actionBar.addTab(actionBar.newTab().setText(pagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:org.tunesremote.LibraryBrowseActivity.java
@SuppressLint("NewApi") @Override// ww w . ja v a 2 s . c o m public void onCreate(Bundle saved) { super.onCreate(saved); this.prefs = PreferenceManager.getDefaultSharedPreferences(this); if (this.prefs.getBoolean(this.getString(R.string.pref_fullscreen), true) && Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { this.requestWindowFeature(Window.FEATURE_NO_TITLE); } setContentView(R.layout.act_browse_library); artists = new ArtistsListFragment(); albums = new AllAlbumsListFragment(); playlists = new PlaylistsFragment(); isTablet = findViewById(R.id.frame_artists) != null; if (!isTablet) { (pager = (ViewPager) findViewById(R.id.view_pager)) .setAdapter(new LibraryPagerAdapter(getSupportFragmentManager())); pager.setOnPageChangeListener(this); pager.setOffscreenPageLimit(2); findViewById(R.id.tab_artists).setSelected(true); } else { getSupportFragmentManager().beginTransaction().add(R.id.frame_artists, artists) .add(R.id.frame_albums, albums).add(R.id.frame_playlists, playlists).commit(); registerListener(artists, albums, playlists); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { handler = new TabHandler(); ActionBar ab = getActionBar(); ab.setTitle(R.string.control_menu_library); if (!isTablet) { findViewById(R.id.legacy_tabs).setVisibility(View.GONE); ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); Tab artTab = ab.newTab().setText(R.string.control_menu_artists).setTabListener(handler); Tab albTab = ab.newTab().setText(R.string.control_menu_albums).setTabListener(handler); Tab plyTab = ab.newTab().setText(R.string.control_menu_playlists).setTabListener(handler); ab.addTab(artTab); ab.addTab(albTab); ab.addTab(plyTab); } } }
From source file:com.example.kaow.caltest.MainFrag.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.frag_main);//from w ww . j a v a 2 s.c om // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); final ActionBar actionBar = getActionBar(); // Specify that the Home button should show an "Up" caret, indicating that touching the // button will take the user one step up in the application's hierarchy. actionBar.setDisplayHomeAsUpEnabled(true); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mFoodTitles.length || i < mFoodIcon.length; i++) { actionBar.addTab(actionBar.newTab().setIcon(mFoodIcon[i]).setText(mFoodTitles[i]).setTabListener(this)); } }
From source file:edu.tcfsh.arrivinglaterecordapp.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); getBundle();//from w ww . ja va2 s .co m arrivingLateRecordFragment = new ArrivingLateRecordFragment(dayOfMonth, month, year); // Create the adapter that will return a fragment for each of the three // primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); leavingActivityDialog = new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_LIGHT); leavingActivityDialog.setTitle("??"); leavingActivityDialog.setMessage("?"); leavingActivityDialog.setPositiveButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { savingFileAlertDialog.show(); } }); leavingActivityDialog.setNegativeButton("?", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { } }); savingFileAlertDialog = new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_LIGHT); savingFileAlertDialog.setTitle("??"); savingFileAlertDialog.setMessage("?????"); savingFileAlertDialog.setPositiveButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { arrivingLateRecordFragment.saveArrivingLateRecordFile(); finish(); } }); savingFileAlertDialog.setNegativeButton("?", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { finish(); } }); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is // no hierarchical // parent. actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener // for when the // user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select // the corresponding tab. // We can also use ActionBar.Tab#select() to do this if // we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. // Also specify this Activity object, which implements the // TabListener interface, as the // listener for when this tab is selected. actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.dooweb.flip.TestProfile.java
public void onCreate(Bundle savedInstanceState) { Log.v("profile", "create"); super.onCreate(savedInstanceState); Log.v("profile", "super"); setContentView(R.layout.test_profile); // Create the adapter that will return a fragment for each of the three primary sections // of the app. Log.v("profile", "new adapter"); mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. Log.v("profile", "actionbar"); final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent.//from w ww . j a va2 s.c o m Log.v("profile", "homebutton"); actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. Log.v("profile", "setnav"); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. Log.v("profile", "viewpager"); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by the adapter. // Also specify this Activity object, which implements the TabListener interface, as the // listener for when this tab is selected. actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }