Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid view extraction from OnItemClickMethod
    text
    copied!<p>I have a list View and In the adaptor of this list View i have a method </p> <pre><code>public void onItemClick(AdapterView&lt;?&gt; AdapterView, View View, int position, long id) </code></pre> <p>each row of list contain 3 view </p> <p>xml for row is </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@android:color/white" android:padding="5dp"&gt; &lt;TextView android:id="@+id/name" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="20dp" android:textStyle="bold" android:textColor="@android:color/black" android:layout_marginTop="10dp" android:focusable="false"&gt; &lt;/TextView&gt; &lt;TextView android:id="@+id/street" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/name" android:textColor="@android:color/black" android:focusable="false"&gt; &lt;/TextView&gt; &lt;ImageView android:id="@+id/pic" android:src="@drawable/pic" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_marginRight="10dp" android:layout_below="@id/name" android:focusable="false"&gt; &lt;/ImageView&gt; &lt;/RelativeLayout&gt; </code></pre> <p>In OnItemClickMethod i want to find click event on these 3 view. how can i do this? </p> <p>Note: if i am using view.getId() it is returning -1 for first row . so i am unable to use this one.</p> <pre><code>if(view.getId() == R.id.name){ dotask(); } </code></pre> <p>Update: I just call onClick method inside getView Method </p> <pre><code>setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Toast.makeText(context,position.toString(), Toast.LENGTH_LONG).show(); } }); </code></pre> <p>and my problem get solved. </p> <p>Thanks <strong>FunkTheMonk and Vikky.</strong></p>
 

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