Java Code Examples for android.app.ActionBar#setNavigationMode()

The following examples show how to use android.app.ActionBar#setNavigationMode() . 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: MainActivity.java    From desCharts with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.ac_main);
   
   // setup the action bar to show a dropdown list
   final ActionBar aBar = getActionBar();
   aBar.setDisplayShowTitleEnabled(false);
   aBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

   // setup the dropdown list navigation in the action bar
   aBar.setListNavigationCallbacks(
      new ArrayAdapter<String>(aBar.getThemedContext(),
         android.R.layout.simple_list_item_1,android.R.id.text1,
         new String[] { getString(R.string.title_section1),
                        getString(R.string.title_section2),
                        getString(R.string.title_section3),
                        getString(R.string.title_section4),
                        getString(R.string.title_section5),
                        getString(R.string.title_section6)  } ),this);
}
 
Example 2
Source File: FragmentNestingStatePagerSupport.java    From V.FlyoutTest with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.pager);
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText("Simple"),
            CountingFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("List"),
            FragmentPagerSupport.ArrayListFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("Cursor"),
            CursorFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("Tabs"),
            FragmentTabsFragment.class, null);

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }
}
 
Example 3
Source File: FragmentNestingPagerSupport.java    From V.FlyoutTest with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.pager);
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText("Simple"),
            CountingFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("List"),
            FragmentPagerSupport.ArrayListFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("Cursor"),
            CursorFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("Tabs"),
            FragmentTabsFragment.class, null);

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }
}
 
Example 4
Source File: MainActivity.java    From android-viewpager-transformers with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    int selectedPage = 0;
    if (savedInstanceState != null) {
        mSelectedItem = savedInstanceState.getInt(KEY_SELECTED_CLASS);
        selectedPage = savedInstanceState.getInt(KEY_SELECTED_PAGE);
    }

    final ArrayAdapter<TransformerItem> actionBarAdapter = new ArrayAdapter<TransformerItem>(getApplicationContext(),
            android.R.layout.simple_list_item_1, android.R.id.text1, TRANSFORM_CLASSES);

    final ActionBar actionBar = getActionBar();
    actionBar.setListNavigationCallbacks(actionBarAdapter, this);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE);

    setContentView(R.layout.activity_main);

    mAdapter = new PageAdapter(getSupportFragmentManager());

    mPager = (ViewPager) findViewById(R.id.container);
    mPager.setAdapter(mAdapter);
    mPager.setCurrentItem(selectedPage);

    actionBar.setSelectedNavigationItem(mSelectedItem);
}
 
Example 5
Source File: DialtactsActivity.java    From coursera-android with MIT License 5 votes vote down vote up
/**
 * Goes back to usual Phone UI with tags. Previously selected Tag and associated Fragment
 * should be automatically focused again.
 */
private void exitSearchUi() {
    final ActionBar actionBar = getActionBar();

    // Hide the search fragment, if exists.
    if (mSearchFragment != null) {
        mSearchFragment.setUserVisibleHint(false);

        final FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.hide(mSearchFragment);
        transaction.commitAllowingStateLoss();
    }

    // We want to hide SearchView and show Tabs. Also focus on previously selected one.
    actionBar.setDisplayShowCustomEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    for (int i = 0; i < TAB_INDEX_COUNT; i++) {
        sendFragmentVisibilityChange(i, i == mViewPager.getCurrentItem());
    }

    // Before exiting the search screen, reset swipe state.
    mDuringSwipe = false;
    mUserTabClick = false;

    mViewPager.setVisibility(View.VISIBLE);

    hideInputMethod(getCurrentFocus());

    // Request to update option menu.
    invalidateOptionsMenu();

    // See comments in onActionViewExpanded()
    mSearchView.onActionViewCollapsed();
    mInSearchUi = false;
}
 
Example 6
Source File: MainActivity.java    From androidtestdebug with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if(savedInstanceState != null && savedInstanceState.getInt("theme", -1) != -1) {
        mThemeId = savedInstanceState.getInt("theme");
        this.setTheme(mThemeId);
    }
            
    setContentView(R.layout.main);

    Directory.initializeDirectory(new OnDirectoryChanged());
    
    ActionBar bar = getActionBar();

    int i;
    for (i = 0; i < Directory.getCategoryCount(); i++) {
        bar.addTab(bar.newTab().setText(Directory.getCategory(i).getName())
                .setTabListener(this));
    }

    mActionBarView = getLayoutInflater().inflate(
            R.layout.action_bar_custom, null);

    bar.setCustomView(mActionBarView);
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO);
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayShowHomeEnabled(true);

    // If category is not saved to the savedInstanceState,
    // 0 is returned by default.
    if(savedInstanceState != null) {
        int category = savedInstanceState.getInt("category");
        bar.selectTab(bar.getTabAt(category));
    }
}
 
Example 7
Source File: HostActivity.java    From blog-nested-fragments-backstack with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_host);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);


    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.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 < mSectionsPagerAdapter.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 callback (listener) for when
        // this tab is selected.
        actionBar.addTab(
                actionBar.newTab()
                        .setText(mSectionsPagerAdapter.getPageTitle(i))
                        .setTabListener(this));
    }
}
 
Example 8
Source File: MainActivity.java    From androidtestdebug with MIT License 5 votes vote down vote up
@Override
  public void onCreate(Bundle savedInstanceState) {		
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
	.detectActivityLeaks()
	.penaltyLog().build());

      super.onCreate(savedInstanceState);

      if(savedInstanceState != null && savedInstanceState.getInt("theme", -1) != -1) {
          mThemeId = savedInstanceState.getInt("theme");
          this.setTheme(mThemeId);
      }
              
      setContentView(R.layout.main);

      Directory.initializeDirectory(new OnDirectoryChanged());
      
      ActionBar bar = getActionBar();

      int i;
      for (i = 0; i < Directory.getCategoryCount(); i++) {
          bar.addTab(bar.newTab().setText(Directory.getCategory(i).getName())
                  .setTabListener(this));
      }

      mActionBarView = getLayoutInflater().inflate(
              R.layout.action_bar_custom, null);

      bar.setCustomView(mActionBarView);
      bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO);
      bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
      bar.setDisplayShowHomeEnabled(true);

      // If category is not saved to the savedInstanceState,
      // 0 is returned by default.
      if(savedInstanceState != null) {
          int category = savedInstanceState.getInt("category");
          bar.selectTab(bar.getTabAt(category));
      }
  }
 
Example 9
Source File: MainActivity.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);

	// Set up the action bar to show a dropdown list.
	final ActionBar actionBar = getActionBar();
	actionBar.setDisplayShowTitleEnabled(false);
	actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

	final String[] dropdownValues = getResources().getStringArray(
			R.array.dropdown);

	// Specify a SpinnerAdapter to populate the dropdown list.
	ArrayAdapter<String> adapter = new ArrayAdapter<String>(
			actionBar.getThemedContext(),
			android.R.layout.simple_spinner_item, android.R.id.text1,
			dropdownValues);

	adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

	// Set up the dropdown list navigation in the action bar.
	actionBar.setListNavigationCallbacks(adapter, this);

	// Use getActionBar().getThemedContext() to ensure
	// that the text color is always appropriate for the action bar
	// background rather than the activity background.
}
 
Example 10
Source File: MainActivity.java    From speech-android-sdk with Apache License 2.0 5 votes vote down vote up
@Override
   protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	// Strictmode needed to run the http/wss request for devices > Gingerbread
	if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD) {
		StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
				.permitAll().build();
		StrictMode.setThreadPolicy(policy);
	}
			
	//setContentView(R.layout.activity_main);
       setContentView(R.layout.activity_tab_text);

       ActionBar actionBar = getActionBar();
       actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

       tabSTT = actionBar.newTab().setText("Speech to Text");
       tabTTS = actionBar.newTab().setText("Text to Speech");

       tabSTT.setTabListener(new MyTabListener(fragmentTabSTT));
       tabTTS.setTabListener(new MyTabListener(fragmentTabTTS));

       actionBar.addTab(tabSTT);
       actionBar.addTab(tabTTS);

       //actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#B5C0D0")));
}
 
Example 11
Source File: NavigationDrawerFragment.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
private void showGlobalContextActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    String app_name = actionBar.getThemedContext().getString(R.string.app_name);
    if(XDripViewer.isNightScoutMode(actionBar.getThemedContext())) {
        app_name = app_name + " nightscout";
    }
    actionBar.setTitle(app_name);
}
 
Example 12
Source File: ViewPagerActivity.java    From SensorTag-CC2650 with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  // Log.d(TAG, "onCreate");
  super.onCreate(savedInstanceState);
  setContentView(mResourceFragmentPager);

  // Set up the action bar
  final ActionBar actionBar = getActionBar();
  actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
  ImageView view = (ImageView) findViewById(android.R.id.home);
  view.setPadding(10, 0, 20, 10);

  // Set up the ViewPager with the sections adapter.
  mViewPager = (ViewPager) findViewById(mResourceIdPager);
  mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
    @Override
    public void onPageSelected(int n) {
      // Log.d(TAG, "onPageSelected: " + n);
      actionBar.setSelectedNavigationItem(n);
    }
  });
  // Create the adapter that will return a fragment for each section
  mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

  // Set up the ViewPager with the sections adapter.
  mViewPager.setAdapter(mSectionsPagerAdapter);
}
 
Example 13
Source File: ResultActivity.java    From bankomatinfos with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_result);
	_showQuickLog = (_controller.getCardInfoNullSafe(this).getQuickLog()
			.size() > 0);
	_showEmvLog = _controller.getCardInfoNullSafe(this).isEmvCard();
	if (_showEmvLog && _showQuickLog) {
		_numLogTabs = 2;
	} else {
		_numLogTabs = 1;
	}
	_fragmentResultInfos = new ResultInfosListFragment();
	if (_showEmvLog) {
		_fragmentResultEmxTxList = new ResultEmvTxListFragment();
	}
	if (_showQuickLog) {
		_fragmentResultQuickTxList = new ResultQuickTxListFragment();
	}
	_fragmentResultLog = new ResultLogFragment();

	// Set up the action bar.
	final ActionBar actionBar = getActionBar();
	actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

	// Create the adapter that will return a fragment for each of the
	// primary sections of the app.
	_sectionsPagerAdapter = new SectionsPagerAdapter(
			getSupportFragmentManager());

	// Set up the ViewPager with the sections adapter.
	_viewPager = (ViewPager) findViewById(R.id.pager);
	_viewPager.setAdapter(_sectionsPagerAdapter);

	// When swiping between different sections, select the corresponding
	// tab. We can also use ActionBar.Tab#select() to do this if we have
	// a reference to the Tab.
	_viewPager
			.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 < _sectionsPagerAdapter.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 callback (listener) for when
		// this tab is selected.
		actionBar.addTab(actionBar.newTab()
				.setText(_sectionsPagerAdapter.getPageTitle(i))
				.setTabListener(this));
	}
}
 
Example 14
Source File: MainActivity.java    From remoteyourcam-usb with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (AppConfig.LOG) {
        Log.i(TAG, "onCreate");
    }

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    if (!getResources().getConfiguration().isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE)) {
        getWindow()
                .setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else {
        isLarge = true;
    }

    setContentView(R.layout.session);

    settings = new AppSettings(this);

    ActionBar bar = getActionBar();

    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayHomeAsUpEnabled(false);
    bar.addTab(bar.newTab().setText("Session").setTabListener(new MyTabListener(new TabletSessionFragment())));
    bar.addTab(bar.newTab().setText("Gallery").setTabListener(new MyTabListener(new GalleryFragment())));

    int appVersionCode = -1;
    try {
        appVersionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
    } catch (NameNotFoundException e) {
        // nop
    }

    if (settings.showChangelog(appVersionCode)) {
        showChangelog();
    }

    ptp = PtpService.Singleton.getInstance(this);
}
 
Example 15
Source File: MainActivity.java    From AndroidCharts with MIT License 4 votes vote down vote up
public void restoreActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(mTitle);
}
 
Example 16
Source File: ActionBarDisplayOptions.java    From codeexamples-android with Eclipse Public License 1.0 4 votes vote down vote up
public void onClick(View v) {
    final ActionBar bar = getActionBar();
    int flags = 0;
    switch (v.getId()) {
        case R.id.toggle_home_as_up:
            flags = ActionBar.DISPLAY_HOME_AS_UP;
            break;
        case R.id.toggle_show_home:
            flags = ActionBar.DISPLAY_SHOW_HOME;
            break;
        case R.id.toggle_use_logo:
            flags = ActionBar.DISPLAY_USE_LOGO;
            break;
        case R.id.toggle_show_title:
            flags = ActionBar.DISPLAY_SHOW_TITLE;
            break;
        case R.id.toggle_show_custom:
            flags = ActionBar.DISPLAY_SHOW_CUSTOM;
            break;

        case R.id.toggle_navigation:
            bar.setNavigationMode(
                    bar.getNavigationMode() == ActionBar.NAVIGATION_MODE_STANDARD
                            ? ActionBar.NAVIGATION_MODE_TABS
                            : ActionBar.NAVIGATION_MODE_STANDARD);
            return;
        case R.id.cycle_custom_gravity:
            ActionBar.LayoutParams lp = (ActionBar.LayoutParams) mCustomView.getLayoutParams();
            int newGravity = 0;
            switch (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
                case Gravity.LEFT:
                    newGravity = Gravity.CENTER_HORIZONTAL;
                    break;
                case Gravity.CENTER_HORIZONTAL:
                    newGravity = Gravity.RIGHT;
                    break;
                case Gravity.RIGHT:
                    newGravity = Gravity.LEFT;
                    break;
            }
            lp.gravity = lp.gravity & ~Gravity.HORIZONTAL_GRAVITY_MASK | newGravity;
            bar.setCustomView(mCustomView, lp);
            return;
    }

    int change = bar.getDisplayOptions() ^ flags;
    bar.setDisplayOptions(change, flags);
}
 
Example 17
Source File: MainActivity.java    From retroband with Apache License 2.0 4 votes vote down vote up
/*****************************************************
 *	 Overrided methods
 ******************************************************/

@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	
	//----- System, Context
	mContext = this;//.getApplicationContext();
	mActivityHandler = new ActivityHandler();
	AppSettings.initializeAppSettings(mContext);
	
	setContentView(R.layout.activity_main);

	// Load static utilities
	mUtils = new Utils(mContext);
	
	// Set up the action bar.
	final ActionBar actionBar = getActionBar();
	actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

	// Create the adapter that will return a fragment for each of the primary sections of the app.
	mFragmentManager = getSupportFragmentManager();
	mSectionsPagerAdapter = new LLFragmentAdapter(mFragmentManager, mContext, this, mActivityHandler);

	// Set up the ViewPager with the sections adapter.
	mViewPager = (ViewPager) findViewById(R.id.pager);
	mViewPager.setAdapter(mSectionsPagerAdapter);

	// When swiping between different sections, select the corresponding tab.
	mViewPager.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 < mSectionsPagerAdapter.getCount(); i++) {
		// Create a tab with text corresponding to the page title defined by the adapter.
		actionBar.addTab(actionBar.newTab()
				.setText(mSectionsPagerAdapter.getPageTitle(i))
				.setTabListener(this));
	}
	
	// Setup views
	mImageBT = (ImageView) findViewById(R.id.status_title);
	mImageBT.setImageDrawable(getResources().getDrawable(android.R.drawable.presence_invisible));
	mTextStatus = (TextView) findViewById(R.id.status_text);
	mTextStatus.setText(getResources().getString(R.string.bt_state_init));
	
	// Do data initialization after service started and binded
	doStartService();
}
 
Example 18
Source File: MainActivity.java    From remoteyourcam-usb with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (AppConfig.LOG) {
        Log.i(TAG, "onCreate");
    }

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    if (!getResources().getConfiguration().isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE)) {
        getWindow()
                .setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else {
        isLarge = true;
    }

    setContentView(R.layout.session);

    settings = new AppSettings(this);

    ActionBar bar = getActionBar();

    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayHomeAsUpEnabled(false);
    bar.addTab(bar.newTab().setText("Session").setTabListener(new MyTabListener(new TabletSessionFragment())));
    bar.addTab(bar.newTab().setText("Gallery").setTabListener(new MyTabListener(new GalleryFragment())));

    int appVersionCode = -1;
    try {
        appVersionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
    } catch (NameNotFoundException e) {
        // nop
    }

    if (settings.showChangelog(appVersionCode)) {
        showChangelog();
    }

    ptp = PtpService.Singleton.getInstance(this);
}
 
Example 19
Source File: MainActivity.java    From codeexamples-android with Eclipse Public License 1.0 4 votes vote down vote up
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
        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));
    }
}
 
Example 20
Source File: MainActivity.java    From v2ex-daily-android with Apache License 2.0 4 votes vote down vote up
public void restoreActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(mTitle);
}