i am using the following code. But the alert dialog dismiss is not happening. I am using custom view which has a list view, i am trying on list item click, alert dialog should be dismiss. On item click listener is working but alert dialog is not dismissing. Can any body help me out.
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();
}
});
Try this and let me know what happen,