如何在Android中自定义Spinner

时间:2012-07-02 08:07:48

标签: android helper

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

enter image description here

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

像这样

enter image description here

1 个答案:

答案 0 :(得分:0)

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);