Android ListView item from custom adapter not selectable
<p>I'm making a custom adapter so that I can display a list of items with icons which looks like the menu that comes up when you long click the home screen.</p>

<p>For some reason though the list items are not clickable. The can be navigated to with the D-pad but they cannot be clicked in any way. I thought maybe the problem was with the AlertDialog I was using so I replaced a working adapter I had elsewhere but I have the same issue there. </p>

<p>My adapter looks like this:</p>

<pre><code>ArrayList&lt;IconListItem&gt; mItems;
LayoutInflater mInflater;

public IconListAdapter(Context context, ArrayList&lt;IconListItem&gt; items) {
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mItems = items;
}

public IconListAdapter(Context context) { 
    this(context, new ArrayList&lt;IconListItem&gt;()); 
}

public void add(IconListItem item) {
    mItems.add(item);
    notifyDataSetChanged();
    return item;
}

public void remove(IconListItem item) {
    mItems.remove(item);
    notifyDataSetChanged();
}

@Override
public int getCount() {
    return mItems.size();
}

@Override
public IconListItem getItem(int position) {
    return mItems.get(position);
}

@Override
public long getItemId(int position) {
    return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View view;
    if(convertView == null){
        view = mInflater.inflate(R.layout.two_line_icon_list_item, null);
    } else {
        view = convertView;
    }


    IconListItem item = mItems.get(position);
    TextView lineOne = (TextView) view.findViewById(R.id.firstLine);
    TextView lineTwo = (TextView) view.findViewById(R.id.secondLine);
    ImageView iconImage = (ImageView) view.findViewById(R.id.icon);

    lineOne.setVisibility(View.VISIBLE);
    lineTwo.setVisibility(View.VISIBLE);
    iconImage.setVisibility(View.VISIBLE);

    lineOne.setText(item.getText());

    if (item.getSubtext() == null)
        lineTwo.setVisibility(View.GONE);
    else 
        lineTwo.setText(item.getSubtext());



    if (item.getIcon() == null)
        iconImage.setVisibility(View.GONE);
    else 
        iconImage.setImageDrawable(item.getIcon());


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

<p>And the XML it's inflating:</p>

<pre><code>&lt;LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="6dip"
&gt;
    &lt;ImageView
        android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_marginRight="6dip"
    /&gt;
    &lt;LinearLayout
        android:orientation="vertical"  
        android:layout_width="wrap_content"
        android:layout_weight="1"
        android:layout_height="fill_parent"
    &gt;
        &lt;TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center_vertical"
            android:id="@+id/firstLine"
            android:ellipsize="marquee"
            android:inputType="text"
        /&gt;
        &lt;TextView  
            android:layout_width="wrap_content"
            android:layout_height="0dip"
            android:layout_weight="1"          
            android:ellipsize="marquee"
            android:id="@+id/secondLine"
            android:inputType="text"
        /&gt;           
    &lt;/LinearLayout&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>EDIT:</p>

<p>When I say they are not clickable, I mean that they items do not highlight in orange when I press them nor does onItemClick ever get called.</p>

<p>In my code I have this, a different adapter for another purpose and it works perfectly</p>

<pre><code>this.foos= foos;
fa = new FooAdapter(this.foos);
fooList.setAdapter(fa);

// View the details for an item when it is selected
fooList.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2,
            long arg3) {
        Intent i = new Intent(MyActivity.this, MyOtherActivity.class);
        i.putExtra("foo", ((fooAdapter)arg0.getAdapter()).getItem(arg2));
        i.putExtra("list_position", arg2);
        MyActivity.this.startActivityForResult(i, 0);
    }
});
</code></pre>

<p>But when I swap out the first 3 lines for </p>

<pre><code>IconListAdapter ila = new IconListAdapter(this);
ila.add(0, "Test 1", android.R.drawable.ic_menu_mylocation);
ila.add(0, "Test 2", android.R.drawable.ic_menu_edit);
ila.add(0, "Test 3", android.R.drawable.ic_menu_search);
groupList.setAdapter(ila);
</code></pre>

<p>it stops working.</p>
