1

我正在使用一个包含 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();
4

1 回答 1

2

更改 listSpecialityView 上的调用顺序。设置 click listener 后尝试设置适配器。

同样在点击监听器中,调用 dialog.dismiss() 后调用 showDialog(1)

于 2012-08-01T14:15:21.570 回答