Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid ListView setOnItemClickListener not working
    primarykey
    data
    text
    <p>I am trying to make a ListView with TextViews, I want each textview to be able to be clicked and based on it's position a Fragment is pulled up. However, the itemOnClickListener seems to not even be called.</p> <pre><code> mDrawerList = (ListView) findViewById(R.id.devices_drawer); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList.setAdapter(new ArrayAdapter&lt;String&gt;(this, R.layout.drawer_list_item, drawerInfo)); mDrawerList.setItemsCanFocus(false); mDrawerList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, final int pos, long id) { Log.d(TAG, "CLICKED " + pos); selectDevice(pos); } }); </code></pre> <p>here's the xml for the list item:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;TextView android:id="@+id/deviceText" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="center" android:textAppearance="?android:attr/textAppearanceLarge" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>List view xml file:</p> <pre><code>&lt;android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;ListView android:id="@+id/devices_drawer" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="left" android:background="#111" android:choiceMode="singleChoice" android:divider="@android:color/transparent" android:dividerHeight="0dp" /&gt; &lt;FrameLayout android:id="@+id/content_frame" android:layout_width="match_parent" android:layout_height="match_parent" /&gt; &lt;/android.support.v4.widget.DrawerLayout&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload