怎么判断里面有没有dismiss()方法呢?

我用AlertDialog.Builder dialog = new AlertDialog.Builder(this)定义了一个dialog,可是在setOnItemClickListener()里面怎么有没有dismiss()方法呢?AlertDialog.Builder dialog = new AlertDialog.Builder(getApplicationContext());dialog.setTitle("TITLE");dialog.setView(view);dialog.show();listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapter, View view, int pos, long id) { dialog.dismiss() // dismiss is not there. }});

慕村225694
浏览 215回答 1
1回答

繁星点点滴滴

你创建的是DialogBuilder而不是Dialog,你应该这样创建dialog:AlertDialog.Builder builder = newAlertDialog.Builder(this);builder.setCancelable(true);builder.setIcon(android.R.drawable.ic_dialog_alert);builder.setTitle("...");builder.setMessage("message");builder.setNegativeButton("OK", null);AlertDialog dlg = builder.create();
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java
Cocos2d-x