我有代码,不幸的是它不能正常工作。更具体地说,我们不能从第二个微调器中进行选择。这是代码。预先感谢您的帮助。
public class Zamiana extends Activity {
public Spinner spinner1;
public Spinner spinner2;
final ArrayList<Spanned> kon = new ArrayList<Spanned>();
[...]
spinner1 = (Spinner) findViewById(R.id.test);
spinner2 = (Spinner) findViewById(R.id.test2);
ArrayList<Spanned> adapter = new ArrayList<Spanned>();
adapter.add(Html.fromHtml("t0"));
adapter.add(Html.fromHtml("t1"));
adapter.add(Html.fromHtml("t2"));
[...]
ArrayAdapter<Spanned> kontrol = new ArrayAdapter<Spanned>(this,
android.R.layout.simple_spinner_item, adapter);
kontrol.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner1.setAdapter(kontrol);
spinner1.setOnItemSelectedListener(wyznacz);
spinner1.setOnItemSelectedListener(wyznacz);
ArrayAdapter<Spanned> kontrola = new ArrayAdapter<Spanned>(this,
android.R.layout.simple_spinner_item, kon);
kontrola.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner2.setAdapter(kontrola);
}
public OnItemSelectedListener wyznacz=new OnItemSelectedListener(){
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
switch(arg2){
case 0:
kon.clear();
kon.add(Html.fromHtml("t0"));
break;
case 1:
kon.clear();
kon.add(Html.fromHtml("t1"));
break;
case 2:
kon.clear();
kon.add(Html.fromHtml("t2"));
break;
[...]
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
};
非常感谢您的所有帮助:)