1
我有三個Spinners = spinState,spinCounty,& spinCity,我想選擇狀態微調,然後選擇一個狀態,然後第二個微調將給我在該特定狀態內的縣名單,然後選擇縣,然後選擇縣第三個微調會給我一個在特定縣的城市名單,例如:(州)佛羅里達州,(縣)Dade,(城市)邁阿密,畢竟3個已經被選中將該信息傳遞給下一個活動/類。誰能幫忙?這裏是我的代碼如何讓Spinner訪問另一個Spinner?
Spinner spinState,spinCounty,spinCity;
Button bNext;
protected void onCreate(Bundle)
{
//TODO Auto generated method stub
super.oncreate(Bundle)
setContentView(R.layout.info);
Spinner States = (Spinner) findViewById(R.id.spinState);
ArrayAdapter USstates = ArrayAdapter.createFromResource(this,
R.array.States, android.R.layout.simple_spinner_item);
USstates.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
States.setAdapter(USstates);
Spinner Counties = (Spinner) findViewById(R.id.spinCounty);
ArrayAdapter UScounties = ArrayAdapter.createFromResource(this,
R.array.Counties, android.R.layout.simple_spinner_item);
UScounties.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
Counties.setAdapter(UScounties);
Spinner Cities = (Spinner) findViewById(R.id.spinCity);
ArrayAdapter UScities = ArrayAdapter.createFromResource(this,
R.array.Cities,android.R.layout.simple_spinner_item);
UScities.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
Cities.setAdapter(UScities);
initialize();
bNext.setOnClickListener(this);
}
我應該使用什麼樣的代碼?誰可以回答你可以使用我的確切變量,所以我不會感到困惑,在此先感謝。