Android的动作条微调选定的项目,字幕和下拉列表字幕、动作、项目、列表

2023-09-12 02:02:24 作者:良人痞性

我怎么能做出微调的操作栏中有不同的项目为选中状态(显示在操作栏上方),那么一个在下拉列表? 例子是谷歌的邮件有微调的动作栏:

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:

他们怎么实现这个功能? 我可以改变动作栏选中的项目,而不会影响同一项目中的下拉列表? 他们怎么改选定的项目在操作栏中有两行不同的字体,但并不影响下拉列表项? 这可能与操作栏飞旋在ICS和操作栏夏洛克默认实现这个功能,还是应该尝试与自定义视图?

任何源$ C ​​$ C,补习或文档将是非常有益的。 我已经有绑定微调与适配器行动起来吧,我有列表中的下拉菜单,但不会影响在下拉列表中的项目,我不能以任何方式修改项目(因为它们是同一个东西)。

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);
  }
 
精彩推荐
图片推荐