Example usage for android.app ActionBar setListNavigationCallbacks

List of usage examples for android.app ActionBar setListNavigationCallbacks

Introduction

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

Prototype

@Deprecated
public abstract void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener callback);

Source Link

Document

Set the adapter and navigation callback for list navigation mode.

Usage

From source file:com.aknowledge.v1.automation.RemoteActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_remote);
    myApp = (PyHomeController) getApplication();

    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    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, new String[] { "All" }),
            this);

}

From source file:net.sf.diningout.app.ui.RestaurantsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ActionBar ab = getActionBar();
    ab.setDisplayShowTitleEnabled(false);
    ab.setNavigationMode(NAVIGATION_MODE_LIST);
    ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.restaurants_navigation, R.id.sort,
            res().getStringArray(R.array.restaurants_sort));
    adapter.setDropDownViewResource(R.layout.restaurants_navigation_item);
    ab.setListNavigationCallbacks(adapter, this);
    ab.setSelectedNavigationItem(mSort); // restore when rotating with navigation drawer open
    setContentView(R.layout.restaurants_activity);
    if (mDrawerLayout != null) {
        setDrawerLayout(mDrawerLayout);//from ww  w  .  j  a  v a 2  s.co m
    }
    /* set up the map if it was previously showing */
    MapFragment map = map();
    if (map != null) {
        map.getMapAsync(this);
    }
    getLoaderManager().initLoader(0, null, this); // need already to support config changes
}

From source file:com.actionbarsherlock.sample.styled.MainActivityICS.java

/** Called when the activity is first created. */
@Override/* w ww  . ja  v  a  2  s.c  o  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_PROGRESS);

    setContentView(R.layout.main);
    final ActionBar ab = getActionBar();

    // set defaults for logo & home up
    ab.setDisplayHomeAsUpEnabled(showHomeUp);
    ab.setDisplayUseLogoEnabled(useLogo);

    // set up tabs nav
    for (int i = 1; i < 4; i++) {
        ab.addTab(ab.newTab().setText("Tab " + i).setTabListener(this));
    }

    // set up list nav
    ab.setListNavigationCallbacks(
            ArrayAdapter.createFromResource(ab.getThemedContext(), R.array.sections,
                    android.R.layout.simple_spinner_dropdown_item),
            //              .createFromResource(this, R.array.sections,
            //                      android.R.layout.simple_spinner_dropdown_item),
            new OnNavigationListener() {
                @Override
                public boolean onNavigationItemSelected(int itemPosition, long itemId) {
                    // FIXME add proper implementation
                    //rotateLeftFrag();
                    return false;
                }
            });

    // default to tab navigation
    showTabsNav();

    // create a couple of simple fragments as placeholders
    //        final int MARGIN = 16;
    //        leftFrag = new RoundedColourFragment(getResources().getColor(
    //                R.color.android_green), 1f, MARGIN, MARGIN / 2, MARGIN, MARGIN);
    //        rightFrag = new RoundedColourFragment(getResources().getColor(
    //                R.color.honeycombish_blue), 2f, MARGIN / 2, MARGIN, MARGIN,
    //                MARGIN);
    //
    //        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    //        ft.add(R.id.root, leftFrag);
    //        ft.add(R.id.root, rightFrag);
    //        ft.commit();

    ((Button) findViewById(R.id.start)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mMode = startActionMode(new AnActionModeOfEpicProportions());
        }
    });
    ((Button) findViewById(R.id.cancel)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mMode != null) {
                mMode.finish();
            }
        }
    });

    ((Button) findViewById(R.id.progress)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mProgress == 100) {
                mProgress = 0;
                mProgressRunner.run();
            }
        }
    });

}

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 w ww.  jav  a2s.c  o 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
}

From source file:nrec.basil.wimuconsole.SensorSettingsActivity.java

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

    // Set up the action bar to show a dropdown list which will
    // contain the various sensors that can be configured.  Some
    // sensors are local (camera) some are remote bluetooth devices
    // (IMU, Barometer etc.)
    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    // 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, getResources().getStringArray(R.array.sensors_list)),
            this);

    // Specify a SpinnerAdapter to populate the wIMU list
    ArrayAdapter<CharSequence> imuAdapter = ArrayAdapter.createFromResource(this, R.array.wimu_list,
            android.R.layout.simple_spinner_item);
    imuAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    imuSpinner = (Spinner) findViewById(R.id.wimulist);
    imuSpinner.setAdapter(imuAdapter);/*  w ww.j  a  va2 s .c  o m*/

    // Load the BASIL start/stop/reset commands
    InputStream input = getResources().openRawResource(R.raw.basilstart);
    try {
        input.read(basilStart, 0, 26);
    } catch (IOException e) {
        Log.e(TAG, "Could not read BASIL start command", e);
    }
    input = getResources().openRawResource(R.raw.basilstop);
    try {
        input.read(basilStop, 0, 26);
    } catch (IOException e) {
        Log.e(TAG, "Could not read BASIL stop command", e);
    }
    input = getResources().openRawResource(R.raw.basilreset);
    try {
        input.read(basilReset, 0, 26);
    } catch (IOException e) {
        Log.e(TAG, "Could not read BASIL reset command", e);
    }

    // Get the default filename for logging
    EditText logfilename = (EditText) findViewById(R.id.logfilename);
    mLogFileName = logfilename.toString();

    // Get local Bluetooth adapter
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    // If the adapter is null, then Bluetooth is not supported
    if (mBluetoothAdapter == null) {
        Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
        finish();
        return;
    }
}

From source file:io.indy.drone.activity.StrikeDetailActivity.java

private void configureActionBar() {
    // Show the Up button in the action bar.
    ActionBar actionBar = getActionBar();

    mSpinnerAdapter = ArrayAdapter.createFromResource(this, R.array.locations_array,
            android.R.layout.simple_spinner_dropdown_item);

    mOnNavigationListener = new ActionBar.OnNavigationListener() {
        public boolean onNavigationItemSelected(int itemPosition, long itemId) {
            onRegionSelected(itemPosition);
            return true;
        }/*from   w ww . java 2 s . c o  m*/
    };

    actionBar.setTitle("");
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);

    try {
        actionBar.setSelectedNavigationItem(SQLDatabase.indexFromRegion(mRegion));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

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 av  a  2 s .c  o m

    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:com.tweetlanes.android.view.HomeActivity.java

private boolean configureListNavigation() {

    if (mSpinnerAdapter == null) {
        return false;
    }/*  www. j av  a2  s . c  o m*/

    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);

    int accountIndex = 0;
    AccountDescriptor currentAccount = getApp().getCurrentAccount();
    if (currentAccount != null) {
        String testScreenName = "@" + currentAccount.getScreenName().toLowerCase();
        for (int i = 0; i < mAdapterStrings.length; i++) {
            if (testScreenName.equals(mAdapterStrings[i].toLowerCase())) {
                accountIndex = i;
                break;
            }
        }
    }
    actionBar.setSelectedNavigationItem(accountIndex);
    actionBar.setDisplayHomeAsUpEnabled(false);
    return true;
}

From source file:com.shafiq.mytwittle.view.HomeActivity.java

private boolean configureListNavigation() {

    if (mSpinnerAdapter == null) {
        return false;
    }//from  www. ja va 2s.  co  m

    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);

    int accountIndex = 0;
    AccountDescriptor currentAccount = getApp().getCurrentAccount();
    if (currentAccount != null) {
        String testScreenName = "@" + currentAccount.getScreenName()
                + (currentAccount.getSocialNetType() == SocialNetConstant.Type.Appdotnet ? " (App.net)"
                        : " (Twitter)");
        for (int i = 0; i < mAdapterStrings.length; i++) {
            if (testScreenName.toLowerCase().equals(mAdapterStrings[i].toLowerCase())) {
                accountIndex = i;
                break;
            }
        }
    }
    actionBar.setSelectedNavigationItem(accountIndex);
    actionBar.setDisplayHomeAsUpEnabled(false);
    return true;
}

From source file:com.tweetlanes.android.core.view.HomeActivity.java

private boolean configureListNavigation() {

    if (mSpinnerAdapter == null) {
        return false;
    }//w ww  .j  a  v a2  s. co m

    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);

    int accountIndex = 0;
    AccountDescriptor currentAccount = getApp().getCurrentAccount();
    if (currentAccount != null) {
        for (int i = 0; i < getApp().getAccounts().size(); i++) {
            if (currentAccount.getAccountKey().equals(getApp().getAccounts().get(i).getAccountKey())) {
                accountIndex = i;
                break;
            }
        }
    }
    actionBar.setSelectedNavigationItem(accountIndex);
    actionBar.setDisplayHomeAsUpEnabled(false);
    return true;
}