我正在使用以下代码。但是警报对话框关闭没有发生。我正在使用具有列表视图的自定义视图,我正在尝试单击列表项,警报对话框应该被关闭。在项目上单击侦听器正在工作,但警报对话框没有关闭。任何机构都可以帮助我。
View titleView = new View(MixContainerInfoActivity.this);
titleView = (View)getLayoutInflater().inflate(R.layout.custom_unit_title, null);
TextView tv = (TextView)titleView.findViewById(R.id.custom_title_txt_view);
tv.setTypeface(typeFace);
tv.setText("CONTAINER OR IMPLEMENT...");
View view = new View(MixContainerInfoActivity.this);
view = (View)getLayoutInflater().inflate(R.layout.unit_list, null);
containerList = (ListView)view.findViewById(R.id.unit_list_view);
ArrayAdapter<Vector> containerAdapter = new UnitMenuAdapter(MixContainerInfoActivity.this, R.layout.custom_unit_list, containerVector);
containerList.setAdapter(containerAdapter);
final AlertDialog.Builder builder = new AlertDialog.Builder(MixContainerInfoActivity.this);
builder.setCustomTitle(titleView);
builder.setView(view);
final AlertDialog alert = builder.create();
alert.show(); //edited here
containerList.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
System.out.println("Item Clicked..");
alert.dismiss();
}
});