我尝试在按下按钮时动态创建微调器。
这就是我所做的:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.leave_balance);
spinner = new Spinner(this);
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item, list);
spinner.setAdapter(spinnerArrayAdapter);
Button b = (Button)findviewbyid(R.id.button1);
b.setonclicklistener(new Onclicklistener){
public void onClick(View v) {
spinner.performClick();
}
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
Toast.maketext(context,"selectedspinner",Toast.LENGTH_SHORT).show();
}
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
}
}
我的问题是我无法得到那个吐司,即微调器 onitemselectedlistner 没有触发。
任何建议将不胜感激..谢谢