一个微调显示单选按钮,接下来不 [英] One spinner shows radio buttons, the next doesn't
本文介绍了一个微调显示单选按钮,接下来不的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个纺纱厂,一个在上对方,就像这样:
I have two spinners, one above each other, like this:
<Spinner
android:layout_height="wrap_content"
android:id="@+id/CitySpinner"
android:layout_width="fill_parent"
android:prompt="@string/city_prompt"
/>
<Spinner
android:layout_height="wrap_content"
android:id="@+id/CountrySpinner"
android:layout_width="fill_parent"
android:prompt="@string/country_prompt"
/>
我把他们像这样
// set the data adapter for the city spinner
spnCity = (Spinner) findViewById(R.id.CitySpinner);
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
R.layout.simple_spinner_item,
mDbHelper.getCities(),
new String[] { KEY_CITY },
new int[] {android.R.id.text1});
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spnCity.setAdapter(adapter);
// set the data adapter for the country spinner
spnCountry = (Spinner) findViewById(R.id.ProviderSpinner);
SimpleCursorAdapter scaCountries = new SimpleCursorAdapter(this,
R.layout.simple_spinner_item,
mDbHelper.getCountries(),
new String[] { KEY_COUNTRY },
new int[] {android.R.id.text1});
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spnCountry.setAdapter(scaCountries);
它们都显示正确的数据,而是先有单选按钮和第二不。任何想法,为什么?
They both display the correct data, but the first has radio buttons and the second doesn't. Any ideas why?
(R.layout.simple_spinner_item是一样的android.R.layout.simple_spinner_item,除了它具有的android:文字颜色=@彩色/黑白
添加)
(R.layout.simple_spinner_item is the same as android.R.layout.simple_spinner_item, except it has android:textColor="@color/black"
added.)
推荐答案
在第二微调,我认为你已经犯了一个错误
写
In second spinner I think you have made a mistake Write
scaCountries.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
所以你的code将
So your code will be
// set the data adapter for the country spinner
spnCountry = (Spinner) findViewById(R.id.ProviderSpinner);
SimpleCursorAdapter scaCountries = new SimpleCursorAdapter(this,
R.layout.simple_spinner_item,
mDbHelper.getCountries(),
new String[] { KEY_COUNTRY },
new int[] {android.R.id.text1});
scaCountries.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spnCountry.setAdapter(scaCountries);
这篇关于一个微调显示单选按钮,接下来不的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文