动作条的风格溢出菜单项 [英] Actionbar styled overflow menu items

查看:186
本文介绍了动作条的风格溢出菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要(如显示在画面不同的背景色为最低),以完全自定义的溢出菜单项。

I need to make fully custom overflow menu items (different background colors as minimum as showed on picture).

这可能吗?

推荐答案

最后一天,我必须实现操作栏Sherlock.And我的情况是一样的你。我有实现适配器我的导航List.Let说:

Last day i have to implement Action Bar Sherlock.And my case was same as yours. I have implement Adapter for my navigation List.Let say:

public class MyNavigationAdapter extends BaseAdapter {
    Context mContext = null;
    String[] mTitles;
    LayoutInflater mLayOutInflater = null;

    public MyNavigationAdapter(Context context, String[] titles) {
        this.mContext = context;
        this.mTitles = titles;
        mLayOutInflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public int getCount() {
        return mTitles.length;
    }

    @Override
    public Object getItem(int arg0) {
        return null;
    }

    @Override
    public long getItemId(int arg0) {
        return 0;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
        if (view == null)
            view = mLayOutInflater.inflate(R.layout.my_list_custom_row, parent,false);
        TextView rowName = (TextView) view.findViewById(R.id.title);
        rowName.setText(mTitles[position]);
        rowName.setBackground(your desire drawle);// yo

u can also set color etc.
//OR

if(position%2==0)
        rowName.setBackgroundColor(Color.RED);
        else
            rowName.setBackgroundColor(Color.BLUE);
        return view;
    }

}

在此之后,你必须在你的活动的onCreate methos写这些线code。

After this,you have to write these line of code in your Activity onCreate methos.

  ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
actionBar.setListNavigationCallbacks(mNavigationAdapterObj, mNavigationListner);

有关详细信息,.Consult 这里

for more information .Consult here.

这篇关于动作条的风格溢出菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆