예제 #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
      mCount = savedInstanceState.getInt(STATE_COUNT);
      mSortName = savedInstanceState.getString(STATE_SORT_NAME);
    }

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    ArrayAdapter<CharSequence> mSpinnerAdapter =
        ArrayAdapter.createFromResource(this, R.array.plays_filter, R.layout.sherlock_spinner_item);
    mSpinnerAdapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
    actionBar.setListNavigationCallbacks(mSpinnerAdapter, this);
  }
  /** Set up action bar navigation list and listener callbacks */
  private void setupActionBarNavigation() {
    // set up spinner adapter for navigation list
    Cursor accountsCursor = mAccountsDbAdapter.fetchAllRecordsOrderedByFullName();

    SpinnerAdapter mSpinnerAdapter =
        new QualifiedAccountNameCursorAdapter(
            getSupportActionBar().getThemedContext(),
            R.layout.sherlock_spinner_item,
            accountsCursor);
    ((ResourceCursorAdapter) mSpinnerAdapter)
        .setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setListNavigationCallbacks(mSpinnerAdapter, mTransactionListNavigationListener);
    actionBar.setDisplayHomeAsUpEnabled(true);

    updateNavigationSelection();
  }
  private void prepareActionBar() {
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    mSpinnerAdapter =
        new ArrayAdapter<CharSequence>(
            this, android.R.layout.simple_spinner_dropdown_item, locations);
    actionBar.setListNavigationCallbacks(
        mSpinnerAdapter,
        new ActionBar.OnNavigationListener() {
          @Override
          public boolean onNavigationItemSelected(int itemPosition, long itemId) {
            return true;
          }
        });
  }
예제 #4
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.movies_activity);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    ArrayAdapter<CharSequence> mActionBarList =
        ArrayAdapter.createFromResource(this, R.array.movie_lists, R.layout.sherlock_spinner_item);
    mActionBarList.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
    actionBar.setListNavigationCallbacks(mActionBarList, this);

    // try to restore previously set nav item
    final SharedPreferences prefs =
        PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    final int navItem = prefs.getInt(AppPreferences.KEY_NAVSELECTION, 0);
    actionBar.setSelectedNavigationItem(navItem);
  }
예제 #5
0
  private void initListNav() {
    ArrayList<String> items = new ArrayList<String>();
    ArrayAdapter<String> nav = null;
    ActionBar bar = getSupportActionBar();

    for (int type : MAP_TYPE_NAMES) {
      items.add(getString(type));
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      nav =
          new ArrayAdapter<String>(
              bar.getThemedContext(), android.R.layout.simple_spinner_item, items);
    } else {
      nav = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, items);
    }

    nav.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    bar.setListNavigationCallbacks(nav, this);
  }
  private void setupActionBar() {
    ActionBar actionBar = getActionBar();
    if (actionBar == null) return;

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

    ActionBar.OnNavigationListener navigationListener =
        new ActionBar.OnNavigationListener() {
          @Override
          public boolean onNavigationItemSelected(int itemPosition, long itemId) {
            ReaderTag tag = (ReaderTag) getActionBarAdapter().getItem(itemPosition);
            if (tag != null) {
              setCurrentTag(tag.getTagName());
              AppLog.d(T.READER, "tag chosen from actionbar: " + tag.getTagName());
            }
            return true;
          }
        };

    actionBar.setListNavigationCallbacks(getActionBarAdapter(), navigationListener);
  }