Android: Handling events in menu
<p>I am trying to implement smth like context menu but with icons </p>

<pre><code>public class MenuItem {
    private  int type; 
    private String nameItem;
    private int imageResource;
}
menu.xml 
// ImageView ant TextView

public final class  MenuItemProvider {
//create our menu items
}

   public class MenuListAdapter extends ArrayAdapter&lt;MenuItem&gt; {
 private Activity context;
 private List&lt;MenuItem&gt; menuItems;

 public MenuListAdapter(Activity context, List&lt;MenuItem&gt; menuItems) {
        super(context, R.menu.menudlg, menuItems);

        this.context = context;
        this.menuItems = menuItems;
      }
 @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = context.getLayoutInflater();
    View row = inflater.inflate(R.menu.menudlg, parent, false);

    TextView label = (TextView) row.findViewById(R.id.text_item);
    label.setText(menuItems.get(position).getName());

    ImageView icon = (ImageView) row.findViewById(R.id.icon_item);
    icon.setImageResource(menuItems.get(position).getImageResource());

    return row;
  }
</code></pre>

<p>}</p>

<p><strong>Question</strong> I don't understand how to handle event in this menu(event of filled menu item), one of the ways send in builder.setAdapter dialogListener ,but i don't know how create them</p>

<pre><code>    listView = getListView();        
    listView.setOnItemClickListener(new OnItemClickListener() {
     @Override
    public void onItemClick(AdapterView&lt;?&gt; a, View v, int position, long id) {
       AlertDialog.Builder builder = new AlertDialog.Builder(context);
       builder.setTitle(title);
       builder.setAdapter(new AccountsTypesListAdapter(context, AccountTypesProvider.accountTypes), dialogListener);
    builder.create().show();
    }
</code></pre>
