set Navigation Selected for ActionBar - Android User Interface

Android examples for User Interface:ActionBar

Description

set Navigation Selected for ActionBar

Demo Code


//package com.java2s;
import android.app.ActionBar;
import android.app.Activity;
import android.widget.ArrayAdapter;

public class Main {
    public static boolean setNavigationSelected(Activity activity,
            ArrayAdapter<String> adapter, String selected) {

        ActionBar actionBar = activity.getActionBar();

        if (actionBar != null) {

            int setPosition = adapter.getPosition(selected);
            actionBar.setSelectedNavigationItem(setPosition);

            return true;

        }//from   w w w.ja  v a  2s. c om

        return false;
    }
}

Related Tutorials