2013.12.03(6) ——— android ActionbarSherlockSample之ListNavigation

package com.actionbarsherlock.sample.demos;import android.content.Context;import android.os.Bundle;import android.widget.ArrayAdapter;import android.widget.TextView;import com.actionbarsherlock.app.ActionBar;import com.actionbarsherlock.app.SherlockActivity;public class ListNavigation extends SherlockActivity implements ActionBar.OnNavigationListener {    private TextView mSelected;    private String[] mLocations;    @Override    public void onCreate(Bundle savedInstanceState) {        setTheme(SampleList.THEME); //Used for theme switching in samples        super.onCreate(savedInstanceState);        setContentView(R.layout.list_navigation);        mSelected = (TextView)findViewById(R.id.text);        mLocations = getResources().getStringArray(R.array.locations);        Context context = getSupportActionBar().getThemedContext();        ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(context, R.array.locations, R.layout.sherlock_spinner_item);        list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);        getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);        getSupportActionBar().setListNavigationCallbacks(list, this);    }    @Override    public boolean onNavigationItemSelected(int itemPosition, long itemId) {        mSelected.setText("Selected: " + mLocations[itemPosition]);        return true;    }}


getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);


设置导航样式,一共有三种样式:

/**     * Standard navigation mode. Consists of either a logo or icon     * and title text with an optional subtitle. Clicking any of these elements     * will dispatch onOptionsItemSelected to the host Activity with     * a MenuItem with item ID android.R.id.home.     */    public static final int NAVIGATION_MODE_STANDARD = android.app.ActionBar.NAVIGATION_MODE_STANDARD;    /**     * List navigation mode. Instead of static title text this mode     * presents a list menu for navigation within the activity.     * e.g. this might be presented to the user as a dropdown list.     */    public static final int NAVIGATION_MODE_LIST = android.app.ActionBar.NAVIGATION_MODE_LIST;    /**     * Tab navigation mode. Instead of static title text this mode     * presents a series of tabs for navigation within the activity.     */    public static final int NAVIGATION_MODE_TABS = android.app.ActionBar.NAVIGATION_MODE_TABS;




更多相关文章

  1. Android(安卓)ApiDemos示例解析(178):Views->Lists->11. Multipl
  2. android wifi 设置 控制开关
  3. Android中dp和px之间进行转换
  4. Android(安卓)如何给Dialog设置宽、高
  5. android修改AlertDialog主题
  6. Android(安卓)各种音量的获取和设置
  7. Android(安卓)Camera照相机
  8. Android(安卓)自制照相机
  9. Android(安卓)开发常用代码片段

随机推荐

  1. android连接mysql数据库
  2. Android系统移植(三)-按键字符表
  3. Android闪屏页动画不起作用的解决方法
  4. android -------- java.net.UnknownServi
  5. android 底片,浮雕,老照片效果
  6. Android的权限机制之—— “沙箱”机制sh
  7. Android发展历程
  8. android 颜色资源
  9. Android studio 动态fragment的用法
  10. android setPersistent