【问题标题】:How to customize Spinner in Android [closed]如何在 Android 中自定义 Spinner [关闭]
【发布时间】:2012-07-02 08:07:47
【问题描述】:

我在我的项目中使用了微调器,但它看起来像

但我希望微调器作为实际的下拉列表。请帮助我。

喜欢这个

【问题讨论】:

  • 通过实际的下拉列表,你的意思是我粘贴在问题中的 1??\
  • 对我来说这看起来像是一个下拉列表。你能详细说明一下吗?
  • 这可以通过使用默认微调器来实现,您不需要为此自定义
  • 不!我想要下拉列表的视图,如下图所示。
  • 是的,就是这样......当你使用时可以实现,cityArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

标签: android helper


【解决方案1】:
city_array = new String[]{city1, city2, city3,....};

ArrayAdapter<String> cityArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,city_array);

cityArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

city_spinner = (Spinner) findViewById(yourSpinner);
city_spinner.setAdapter(cityArrayAdapter);

【讨论】:

    猜你喜欢
    • 2016-06-23
    • 2013-05-17
    • 1970-01-01
    • 1970-01-01
    • 2011-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-23
    相关资源
    最近更新 更多