Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The gmail app uses its own view called CanvasConversationHeaderView that manages its subviews. This method is probably more heavy-weight than what you are looking for.</p> <p>An easier method would be to make the checkbox not "focusable" (as Alex Lockwood suggests) and then attach an onClick in the XML.</p> <pre><code>&lt;CheckBox android:id="@+id/checkBox1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:focusable="false" android:onClick="onCheckboxClicked"/&gt; </code></pre> <p>Then in your activity code add</p> <pre><code>public void onCheckboxClicked(View view) { RelativeLayout rl = (RelativeLayout)view.getParent(); Log.d(TAG, "Checkbox clicked! getTag returned: " + rl.getTag()); } </code></pre> <p>EDIT: How to add a tag from SimpleCursorAdapter.bindView</p> <pre><code>private class MyCursorAdapter extends SimpleCursorAdapter { public MyCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to) { super(context, layout, c, from, to); } @Override public void bindView(View view, Context context, Cursor cursor) { //Log.d(TAG, "Cursor pos: " + cursor.getPosition()); String name = cursor.getString( cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); view.setTag(name); super.bindView(view, context, cursor); } } </code></pre> <p>Note: I set the tag to the View from the bindView call, which is the RelativeLayout at the root of your xml. Look at the onCheckboxClicked method to see how I got the tag.</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