Note that there are some explanatory texts on larger screens.

plurals
  1. POAutoCompleteTextView with custom list: how to set up OnItemClickListener
    primarykey
    data
    text
    <p>I am working on an app which uses tags. Accessing those should be as simple as possible. Working with an AutoCompleteTextView seems appropriate to me. What I want:</p> <ul> <li>existing tags should be displayed in a selectable list with a CheckBox on each item's side</li> <li>existing tags should be displayed UPON FOCUS of AutoCompleteTextView (i.e. not after typing a letter)</li> </ul> <p>What I've done so far is storing tags in a dedicated sqlite3 table. Tags are queried resulting in a Cursor. The Cursor is passed to a SimpleCursorAdapter which looks like this:</p> <pre><code>Cursor cursor = dbHelper.getAllTags(); startManagingCursor(cursor); String[] columns = new String[] { TagsDB._TAG}; int[] to = new int[] { R.id.tv_tags}; SimpleCursorAdapter cursAdapt = new SimpleCursorAdapter(this, R.layout.tags_row, cursor, columns, to); actv.setAdapter(cursAdapt); </code></pre> <p>As you can see I created <strong>tags_row.xml</strong> which looks like this:</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="fill_parent" android:layout_height="wrap_content" android:paddingLeft="4dip" android:paddingRight="4dip" android:orientation="horizontal"&gt; &lt;TextView android:id="@+id/tv_tags" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:textColor="#000" android:onClick="actv_item_click" /&gt; &lt;CheckBox android:id="@+id/cb_tags" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="actv_item_checked" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>It looks like this:</p> <p><a href="http://img708.imageshack.us/img708/5992/devicem.png" rel="nofollow noreferrer">image http://img708.imageshack.us/img708/5992/devicem.png</a></p> <p>So the results are displayed just as I'd want them to. But the TextView's onClick listener does not respond. And I don't have a clue on how to access the data once an item is (de-)selected.</p> <p>Behaviour of the list should be the following:</p> <ul> <li>tapping a CheckBox item should insert/append the corresponding tag into the AutoCompleteTextView (tags will be semicolon-seperated)</li> <li>tapping a TextView item should insert/apped the corresponding tag into the AutoCompleteTextView AND close the list.</li> </ul>
    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.
    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