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

The following examples show how to use android.app.ActionBar#setListNavigationCallbacks() . 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: SpinnerActivity.java    From holoaccent with Apache License 2.0 6 votes vote down vote up
private void initActionBar() {
	ActionBar actionBar = getActionBar();
	if (actionBar == null)
		return;
	
	actionBar.setHomeButtonEnabled(true);
       actionBar.setDisplayHomeAsUpEnabled(true);
	
	actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
	actionBar.setDisplayShowTitleEnabled(false);
	
	actionBar.setListNavigationCallbacks(new ActionBarArrayAdapter(), new ActionBar.OnNavigationListener() {
		@Override public boolean onNavigationItemSelected(int itemPosition, long itemId) {
			return false;
		}
	});
}
 
Example 3
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 4
Source File: ViewPagerTransformerActivity.java    From UltimateAndroid 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<>(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.getDisplayOptions() ^ ActionBar.DISPLAY_SHOW_TITLE);

    setContentView(R.layout.viewpager_transform_activity);

    mAdapter = new PageAdapter(getFragmentManager());

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

    actionBar.setSelectedNavigationItem(mSelectedItem);
}
 
Example 5
Source File: ViewPagerTransformerActivity.java    From UltimateAndroid 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<>(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.getDisplayOptions() ^ ActionBar.DISPLAY_SHOW_TITLE);

    setContentView(R.layout.viewpager_transform_activity);

    mAdapter = new PageAdapter(getFragmentManager());

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

    actionBar.setSelectedNavigationItem(mSelectedItem);
}
 
Example 6
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.
}