Android动作栏微调器选择项目,字幕和下拉列表 [英] Android actionbar spinner selected item, subtitle and dropdown list

查看:184
本文介绍了Android动作栏微调器选择项目,字幕和下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使操作栏中的微调框选择不同的项目(如操作栏顶部所示),然后是下拉列表中的一个?
示例是谷歌邮件与微调在行动栏:

How can I make spinner in action bar to have different item as selected (shown in the action bar top) then the one in the drop down list? Example is google mail with spinner in action bar:


  • 他们是如何实现这一功能的?

  • 可以在动作栏中更改所选项目,而不会影响下拉列表中的相同项目? li>
  • 他们如何更改在动作栏中选定的项目,以便具有两行和不同的字体,但不影响下拉列表中的项目?

  • 这是否可以通过ICS和动作栏sherlock中的动作栏微调器的默认实现来实现,还是应该使用自定义视图?

任何源代码,教程或文档都将非常有用。
我已经在操作栏中绑定了适配器的旋转框,我在下拉菜单中有列表,但是我不能以任何方式修改项目而不影响下拉列表中的项目(因为它们是一样的)。

Any source code, tutorial or document would be really helpful. I already have bind spinner with adapter in action bar and I have list in dropdown menu, but I can not modify in any way item without affecting item in dropdown list (because they are the same thing).

推荐答案

要在动作栏微调中使用与微调框列表不同的视图,可以使用BaseAdapter 或ArrayAdapter,并覆盖一些方法:

To have a different view in the action bar spinner than in the spinner list, you can use a BaseAdapter or an ArrayAdapter and override some methods:

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // Return a view which appears in the action bar.

    return yourCustomView..;
  }

  @Override
  public View getDropDownView(int position, View convertView, ViewGroup parent) {
    // Return a view which appears in the spinner list.

    // Ignoring convertView to make things simpler, considering
    // we have different types of views. If the list is long, think twice!
    return super.getView(position, null, parent);
  }

这篇关于Android动作栏微调器选择项目,字幕和下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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