I'm trying to do AlertDialog with custom list (image + text). I'm using custom adapter, it works, but I don't understand why the onClick event does not work. I had already tried create ListView, set my adapter to it and than set view to my AlertDialog, but I still can not catch the event. What am I doing wrong?
ArrayList<ItemData> list = ItemData.createFromMaterialArray(materials);
        MaterialsAdapter adapter = new MaterialsAdapter(this,
                R.layout.custom_material_item, R.id.text, list);
        AlertDialog.Builder materialTypesDialog = new AlertDialog.Builder(this);
        materialTypesDialog.setTitle(R.string.material);
        materialTypesDialog.setAdapter(adapter, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                // Nothing happens, why???
                Toast.makeText(context, "WORK", Toast.LENGTH_LONG).show();
            }
        });
        materialTypesDialog.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                // Same problem
                Toast.makeText(context, "WORK", Toast.LENGTH_LONG).show();
            }
            @Override
            public void onNothingSelected(AdapterView<?> parent) {
            }
        });
        materialTypesDialog.show();
My adapter, i used similar adapter for spinners and it works fine.
class MaterialsAdapter extends ArrayAdapter<ItemData> {
private int groupId;
Activity context;
ArrayList<ItemData> list;
private LayoutInflater inflater;
/**
 * @param context
 * @param _groupId
 * @param _id
 * @param list
 */
MaterialsAdapter(Activity context, int _groupId, int _id, ArrayList<ItemData>
        list) {
    super(context, _id, list);
    this.list = list;
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    this.groupId = _groupId;
}
/**
 * @param position
 * @param convertView
 * @param parent
 * @return
 */
public View getView(int position, View convertView, ViewGroup parent) {
    View itemView = inflater.inflate(groupId, parent, false);
    ImageView imageView = (ImageView) itemView.findViewById(R.id.image);
    imageView.setImageResource(list.get(position).getImageId());
    TextView textView = (TextView) itemView.findViewById(R.id.text);
    textView.setText(list.get(position).getTextId());
    return itemView;
}
/**
 * @param position
 * @param convertView
 * @param parent
 * @return
 */
public View getDropDownView(int position, View convertView, ViewGroup
        parent) {
    return getView(position, convertView, parent);
}
}
ItemData class
class ItemData {
private String id;
private int textId;
private int imageId;
/**
 * @param id
 * @param textId
 * @param imageId
 */
private ItemData(String id, int textId, int imageId) {
    this.id = id;
    this.textId = textId;
    this.imageId = imageId;
}
/**
 * @return
 */
int getTextId() {
    return textId;
}
/**
 * @return
 */
int getImageId() {
    return imageId;
}
/**
 * @return
 */
String getId() {
    return id;
}
/**
 * @return
 */
static ArrayList<ItemData> createFromMaterialArray(Material[] materials) {
    ArrayList<ItemData> itemDataList = new ArrayList<>();
    for (Material material : materials) {
        itemDataList.add(
                new ItemData(material.getName(),
                        material.textID,
                        material.imageID);
    }
    return itemDataList;
}}
Layout custom_material_item looks like simple LineralLayout with two items(TextView and ImageView).
 
    