Example usage for android.app ActionBar NAVIGATION_MODE_LIST

List of usage examples for android.app ActionBar NAVIGATION_MODE_LIST

Introduction

In this page you can find the example usage for android.app ActionBar NAVIGATION_MODE_LIST.

Prototype

int NAVIGATION_MODE_LIST

To view the source code for android.app ActionBar NAVIGATION_MODE_LIST.

Click Source Link

Document

List navigation mode.

Usage

From source file:com.michael.openexercise.mc_customview.roundimageviewdemo.roundimageviewexample.RoundedImageExampleActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.rounded_image_main_layout);

    getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    getActionBar().setListNavigationCallbacks(ArrayAdapter.createFromResource(getActionBar().getThemedContext(),
            R.array.action_list, android.R.layout.simple_spinner_dropdown_item), this);

    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction().replace(android.R.id.content, new RoundedFragment())
                .commit();/*from w  w  w  . j a  va 2s.  c om*/
    }

}

From source file:com.commonsware.android.feedfrags.FeedsNavActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_nav);//from w w  w.  ja  va 2  s .co m

    ActionBar bar = getActionBar();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        adapter = new ArrayAdapter<Feed>(bar.getThemedContext(), R.layout.row, Feed.getFeeds());
    } else {
        adapter = new ArrayAdapter<Feed>(this, R.layout.row, Feed.getFeeds());
    }

    bar.setListNavigationCallbacks(adapter, new NavListener());
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
    bar.setDisplayHomeAsUpEnabled(true);
}

From source file:com.javierc.albuquerquenow.TransitMap.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Set up the action bar to show a dropdown list.
    actionBar = getActionBar();//from www. j av a 2s  .  c  o m
    actionBar.setDisplayShowHomeEnabled(false);
    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);

    googlemap.getUiSettings().setRotateGesturesEnabled(false);

}

From source file:com.herasymc.cmput301counter.CounterSummaryActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_counter_summary);

    list = CounterList.getInstance(getApplicationContext());
    id = (int) getIntent().getLongExtra("id", -1); // if id is -1, summarize all counters

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

    // Set up the dropdown list navigation in the action bar.
    actionBar.setListNavigationCallbacks(
            // Specify a SpinnerAdapter to populate the dropdown list.
            new ArrayAdapter<String>(actionBar.getThemedContext(), android.R.layout.simple_list_item_1,
                    android.R.id.text1,/* w  ww  . j a v a 2 s .com*/
                    new String[] { getString(R.string.title_summary_minute),
                            getString(R.string.title_summary_hour), getString(R.string.title_summary_day),
                            getString(R.string.title_summary_week), getString(R.string.title_summary_month) }),
            this);
}

From source file:net.pejici.summation.SummationList.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_summation_list);

    // Set up the action bar to show a dropdown list.
    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    recreateSheetsList();// www .j a  v  a  2 s . co m
}

From source file:com.lugia.timetable.MasterActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_master);

    // Set up preferences value of this app if we run it on first time
    PreferenceManager.setDefaultValues(MasterActivity.this, R.xml.setting_preference, false);

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

    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    mFilename = null;/*from w w w  .j a  v a2s. com*/

    mTimeTableFragment = new TimeTableFragment();
    mSubjectListFragment = new SubjectListFragment();

    getSupportFragmentManager().beginTransaction().add(R.id.container, mTimeTableFragment, "TimeTable")
            .add(R.id.container, mSubjectListFragment, "SubjectList").hide(mSubjectListFragment).commit();

    mSpinnerAdapter = new TimeTableSpinnerAdapter(MasterActivity.this, actionBar.getSelectedNavigationIndex());
    mSpinnerAdapter.setViewType(NAV_DAY);

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

From source file:awbb.droid.data.RatingActivity.java

/**
 * {@inheritDoc}/*from ww w  .  j  a  v  a2  s  . c o m*/
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    // set theme
    ((AwbbApplication) getApplication()).applyTheme(this);

    // create activity
    super.onCreate(savedInstanceState);

    // data source
    DatabaseDataSource.create(this);
    DatabaseDataSource.open();

    // load view
    setContentView(R.layout.activity_rating);

    viewPager = (ViewPager) findViewById(R.id.ratingPager);

    // get data from intent
    Intent intent = getIntent();
    long id = intent.getLongExtra(EXTRA_RATING_ID, -1);

    // init
    if (id == -1) {
        rating = new Rating();
    } else {
        rating = RatingDao.get(id);
    }

    // adapter
    adapter = new RatingPagerAdapter(this, getSupportFragmentManager());
    viewPager.setAdapter(adapter);

    // action bar
    final ActionBar actionBar = getActionBar();
    // FIXME
    // http://developer.android.com/training/implementing-navigation/lateral.html#horizontal-paging
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    // ActionBar.TabListener tabListener = new ActionBar.TabListener() {
    //
    // @Override
    // public void onTabUnselected(Tab tab, FragmentTransaction ft) {
    // // TODO Auto-generated method stub
    //
    // }
    //
    // @Override
    // public void onTabSelected(Tab tab, FragmentTransaction ft) {
    // viewPager.setCurrentItem(tab.getPosition());
    // }
    //
    // @Override
    // public void onTabReselected(Tab tab, FragmentTransaction ft) {
    // // TODO Auto-generated method stub
    //
    // }
    //
    // };

    // add tabs
    // for (int i = 0; i < Sensor.values().length + 1; i++) {
    // actionBar.addTab(actionBar.newTab().setText("tab" +
    // i).setTabListener(tabListener));
    // }

    // page swipe
    viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            Log.d(TAG, "onPageSelected position=" + position);
            actionBar.setSelectedNavigationItem(position);
        };

    });
}

From source file:com.miz.mizuu.ShowDetails.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (!MizLib.isPortrait(this))
        if (isFullscreen())
            setTheme(R.style.Theme_Example_Transparent_NoBackGround_FullScreen);
        else//from w w w  .  j  a  va  2  s.  c  o  m
            setTheme(R.style.Theme_Example_Transparent_NoBackGround);
    else if (isFullscreen())
        setTheme(R.style.Theme_Example_Transparent_FullScreen);
    else
        setTheme(R.style.Theme_Example_Transparent);

    getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);

    setContentView(R.layout.viewpager);

    actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    if (spinnerAdapter == null)
        spinnerAdapter = new ActionBarSpinner(this, spinnerItems);

    setTitle(null);

    awesomePager = (ViewPager) findViewById(R.id.awesomepager);
    awesomePager.setOffscreenPageLimit(3); // Required in order to retain all fragments when swiping between them
    awesomePager.setAdapter(new ShowDetailsAdapter(getSupportFragmentManager()));
    awesomePager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
            invalidateOptionsMenu();
        }
    });

    ignorePrefixes = PreferenceManager.getDefaultSharedPreferences(this)
            .getBoolean("prefsIgnorePrefixesInTitles", false);

    // Create and open database
    dbHelper = MizuuApplication.getTvDbAdapter();

    String showId = "";
    // Fetch the database ID of the TV show to view
    if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) {
        showId = getIntent().getStringExtra(SearchManager.EXTRA_DATA_KEY);
    } else {
        showId = getIntent().getStringExtra("showId");
    }

    Cursor cursor = dbHelper.getShow(showId);
    try {
        while (cursor.moveToNext()) {
            thisShow = new TvShow(this, cursor.getString(cursor.getColumnIndex(DbAdapterTvShow.KEY_SHOW_ID)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterTvShow.KEY_SHOW_TITLE)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterTvShow.KEY_SHOW_PLOT)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterTvShow.KEY_SHOW_RATING)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterTvShow.KEY_SHOW_GENRES)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterTvShow.KEY_SHOW_ACTORS)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterTvShow.KEY_SHOW_CERTIFICATION)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterTvShow.KEY_SHOW_FIRST_AIRDATE)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterTvShow.KEY_SHOW_RUNTIME)), ignorePrefixes,
                    cursor.getString(cursor.getColumnIndex(DbAdapterTvShow.KEY_SHOW_EXTRA1)));
        }
    } catch (Exception e) {
        finish();
        return;
    } finally {
        cursor.close();
    }

    if (thisShow == null) {
        finish(); // Finish the activity if the movie doesn't load
        return;
    }

    setupSpinnerItems();

    if (savedInstanceState != null) {
        awesomePager.setCurrentItem(savedInstanceState.getInt("tab", 0));
    }

    // Set the current page item to 1 (episode page) if the TV show start page setting has been changed from TV show details
    if (!PreferenceManager.getDefaultSharedPreferences(this)
            .getString("prefsTvShowsStartPage", getString(R.string.showDetails))
            .equals(getString(R.string.showDetails)))
        awesomePager.setCurrentItem(1);
}

From source file:dude.morrildl.weatherport.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    // We store the list of airports the user has expressed interest in in
    // SharedPrefs, as a list (well, Set) of Strings
    SharedPreferences prefs = getSharedPreferences("prefs", Context.MODE_PRIVATE);

    Set<String> currentSet = prefs.getStringSet("airports", null);
    if (currentSet == null || currentSet.size() < 1) {
        // i.e. first run -- hard-default KSFO to the list
        HashSet<String> defaultSet = new HashSet<String>();
        defaultSet.add("KSFO");
        prefs.edit().putStringSet("airports", defaultSet).commit();
        currentSet = defaultSet;//from   ww w  .  j av a 2  s  . co m
    }

    // enable the nav spinner, which we'll use to pick which airport to look
    // at
    ActionBar bar = getActionBar();
    bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    ArrayList<String> currentList = new ArrayList<String>();
    currentList.addAll(currentSet);
    Collections.sort(currentList);
    adapter = new ArrayAdapter<CharSequence>(bar.getThemedContext(),
            android.R.layout.simple_spinner_dropdown_item);
    adapter.addAll(currentList);

    bar.setListNavigationCallbacks(adapter, new OnNavigationListener() {
        @Override
        public boolean onNavigationItemSelected(int arg0, long arg1) {
            // this re-ups the data whenever the user changes the current
            // airport
            startAsyncFetch(adapter.getItem(arg0).toString());
            return true;
        }
    });

    // Let's set up a fancy new v2 MapView, for the lulz
    mapFragment = new SupportMapFragment();
    pagerAdapter = new TwoFragmentPagerAdapter(this, getSupportFragmentManager(), new DetailsFragment(),
            mapFragment);
    viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setAdapter(pagerAdapter);
    viewPager.setOnPageChangeListener(this);
    // No placemarker on the map because I've always secretly hated that
    // glyph
}