【问题标题】:Creating spinner like in actionBar在 actionBar 中创建微调器
【发布时间】:2014-06-19 18:10:43
【问题描述】:

我想创建类似actionBar's spinner 下拉视图的微调器

我参考了以下问题:

  1. How to make spinner like actionbar in native android
  2. ICS spinner outside ActionBar and not working dropdown menu

但没有找到解决方案的运气。每当我在活动中使用微调器时:

Spinner spinner = (Spinner) findViewById(R.id.spiner_id);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
                R.array.day, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);

在 xml 中:

<Spinner
        android:id="@+id/spiner_id"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

它给出输出:

我想要下拉视图中的微调器,而不是当前的对话框表单。

P.S : 正在使用 4.2+ 版本

@Pankaj Kumar Thnak 让您快速回复。我已将android:spinnerMode="dropdown" 添加到 xml 中的微调器视图中,它工作正常。但下拉列表也包含 RadioButtons。我怎样才能将其从列表中删除?

谢谢!

【问题讨论】:

  • 您的/res/values/style.xml 是否进行了任何更改?如果你做了一个,请尝试撤消它并查看更改。
  • 不,我从未更改过 style.xml 中的任何内容。

标签: android android-actionbar spinner


【解决方案1】:

android:spinnerMode="dropdown" 添加到微调器。

喜欢

<Spinner
        android:id="@+id/spiner_id"
        android:layout_width="wrap_content" 
        android:spinnerMode="dropdown"
        android:layout_height="wrap_content" />

有关删除单选按钮的更多详细信息,请阅读Spinner Button without radio button

【讨论】:

  • 谢谢它为下拉微调器工作。我已经编辑了我的问题,输出 m 现在得到了。我还想删除单选按钮。怎么做?
  • @Manishika 查看我添加到答案中的链接。那是为了删除单选按钮。
猜你喜欢
  • 2012-02-15
  • 1970-01-01
  • 1970-01-01
  • 2012-03-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-12
  • 1970-01-01
相关资源
最近更新 更多