2011-06-24 12 views
1

ん:一つスピナーはラジオボタンを示し、次は私がこのような2つのスピナー、それぞれ一方が他方の上、持ってい

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

のようにそれらを設定します正しいデータですが、最初のラジオボタンはラジオボタンを持ち、2番目のラジオボタンはありません。なぜどんなアイデア?あなたがミスを犯していると思う二スピナーで

(それはandroid:textColor="@color/black"が追加されている以外R.layout.simple_spinner_itemは、android.R.layout.simple_spinner_itemと同じである。)

答えて

2

書く

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

だからあなたのコードは

// 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); 
+0

ああ、よく、今私は愚かな感じになります。 :) –

+0

気にしないでください。誰にでも起こるかもしれない –

関連する問題