我正在使用包含StringArray列表的对话框。 我想在单击StringArray项目时忽略对话框。 但双击后它就被解雇了。
感谢。
final Dialog dialog = new Dialog(Disease.this);
dialog.setCancelable(true);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
final ListView listSpecialityView = new ListView(Disease.this);
listSpecialityView.setCacheColorHint(Color.TRANSPARENT);
listSpecialityView.setAdapter(adapter_list);
listSpecialityView
.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
// Txt_Speciality.setText(Speciality_array[arg2]
// .toString());
// String id = String.valueOf(arg2);
if(immunString.equalsIgnoreCase("immun")){
data = immunizationsStrings[arg2];
}else {
data = Drugs[arg2];
}
showDialog(1);
dialog.dismiss();
//dialog.dismiss();
}
});
dialog.setContentView(listSpecialityView);
dialog.show();
答案 0 :(得分:2)
更改listSpecialityView上的调用顺序。设置点击监听器后尝试设置适配器。
同样在click侦听器中,在调用dialog.dismiss()
之后调用showDialog(1)