0
我能夠在我的視圖中顯示4微調器..現在我想分配順序來選擇微調器上的手段,如果我選擇了第一個微調器,那麼只有我可以選擇第二微調器值,否則它給出了一個警告消息 等on..so如何分配選擇的順序進行微調?請幫助我非常感謝.. 我附上我下面的代碼..如何在微調器選擇中分配順序android
ArrayList<String> aa= MainMenu.ciudad1;
final Spinner ct = (Spinner) findViewById(R.id.Spinner02);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, aa);
ct.setAdapter(adapter);
**ct.setEnabled(false);**
ArrayList<String> estado = MainMenu.estado1;
final Spinner estaddo = (Spinner) findViewById(R.id.Spinner03);
ArrayAdapter<String> adapterestado = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,estado);
estaddo.setAdapter(adapterestado);
estaddo.setEnabled(false);
ArrayList<String> barrio = MainMenu.barrio1;
final Spinner barrio11 = (Spinner) findViewById(R.id.Spinner04);
ArrayAdapter<String> adapterbarrio = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, barrio);
barrio11.setAdapter(adapterbarrio);
**barrio11.setEnabled(false);**
ArrayList<String> type = MainMenu.type;
Spinner type1 = (Spinner) findViewById(R.id.Spinner01);
ArrayAdapter<String> adaptertype= new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, type);
type1.setAdapter(adaptertype);
**type1.setEnabled(true);**
type1.setOnItemSelectedListener(
new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent,
View view, int position, long id)
{
Spinner type1 = (Spinner) findViewById(R.id.Spinner01);
typeselected = (String)type1.getSelectedItem();
estaddo.setEnabled(true);
System.out.println("type selected............:" + typeselected);
}
@Override
public void onNothingSelected(AdapterView<?> parent)
{
}
});
ct.setOnItemSelectedListener(
new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent,
View view, int position, long id)
{
Spinner ct = (Spinner) findViewById(R.id.Spinner02);
cityselected = (String)ct.getSelectedItem();
barrio11.setEnabled(true);
System.out.println("city selected............:" + cityselected);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
//微調estaddo =(微調)findViewById(R.id.Spinner03);
estaddo.setOnItemSelectedListener(
new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent,
View view, int position, long id)
{
Spinner estaddo = (Spinner) findViewById(R.id.Spinner03);
stateselected = (String)estaddo.getSelectedItem();
ct.setEnabled(true);
barrio11.setEnabled(false);
System.out.println("state selected............:" + stateselected);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
}
});
// Spinner barrio = (Spinner) findViewById(R.id.Spinner04);
barrio11.setOnItemSelectedListener(
new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent,
View view, int position, long id)
{
Spinner barrio = (Spinner) findViewById(R.id.Spinner04);
neighbourselected = (String)barrio.getSelectedItem();
System.out.println("neighbour selected............:" + neighbourselected);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
}
});
@saurabh Agnihotri喜......爲什麼u盤type2.setEnabled(真) ; in type1? – SRam
感謝您的幫助,..我怎樣才能給出一個警告消息,如果錯誤的命令微調選擇 – SRam
我想你的第二個微調是type2所以在這種情況下,用戶只能選擇第二個微調,如果他選擇了第二個 – ingsaurabh