Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>well it's much more like arrayAdapter here is sample code</p> <pre><code>public class ListViewFilter extends Activity { private ItemDatabaseHelper itemData; private SimpleCursorAdapter sc; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); itemData=new ItemDatabaseHelper(this); Cursor c=itemData.getAllValues(); sc=new SimpleCursorAdapter(this, R.layout.list_items, c, new String[]{itemData.VALUE}, new int[]{R.id.txtItem}); ListView lv=(ListView)findViewById(R.id.lstItems); lv.setAdapter(sc); sc.setFilterQueryProvider(new FilterQueryProvider() { @Override public Cursor runQuery(CharSequence constraint) { String partialValue = constraint.toString(); return itemData.getAllSuggestedValues(partialValue); } }); EditText etext=(EditText)findViewById(R.id.etxtItemName); etext.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { sc.getFilter().filter(s.toString()); } }); } </code></pre> <p>}</p> <p>and two xml files are listed below</p> <p>main.xml 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="fill_parent" &gt; &lt;EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/etxtItemName" android:layout_alignParentTop="true" /&gt; &lt;ListView android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/lstItems" android:layout_below="@+id/etxtItemName" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>and list_item.xml is</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/txtItem" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;/TextView&gt; </code></pre> <p>Hope this will help you</p>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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