Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid AutoCompleteTextView with Custom Adapter filtering not working
    primarykey
    data
    text
    <p>I've the Custom CustomerAdapter</p> <pre><code>public class CustomerAdapter extends ArrayAdapter&lt;Customer&gt; { private final String MY_DEBUG_TAG = "CustomerAdapter"; private ArrayList&lt;Customer&gt; items; private int viewResourceId; public CustomerAdapter(Context context, int viewResourceId, ArrayList&lt;Customer&gt; items) { super(context, viewResourceId, items); this.items = items; this.viewResourceId = viewResourceId; } public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(viewResourceId, null); } Customer customer = items.get(position); if (customer != null) { TextView customerNameLabel = (TextView) v.findViewById(R.id.customerNameLabel); if (customerNameLabel != null) { customerNameLabel.setText(String.valueOf(customer.getName())); } } return v; } } </code></pre> <p>and <code>customer_auto</code> layout</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/customerNameLabel" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dp" android:textSize="16sp" android:textColor="#000"&gt; &lt;/TextView&gt; </code></pre> <p>and on my <code>public void onCreate</code></p> <pre><code>AutoCompleteTextView customerAutoComplete = (AutoCompleteTextView) findViewById(R.id.autocomplete_customer); CustomerAdapter customerAdapter = new CustomerAdapter(this, R.layout.customer_auto, customerList); customerAutoComplete.setAdapter(customerAdapter); </code></pre> <p>and Customer.java</p> <pre><code>public class Customer implements Parcelable { private int id; private String name = ""; public Customer() { // TODO Auto-generated constructor stub } /** * This will be used only by the MyCreator * * @param source */ public Customer(Parcel source) { /* * Reconstruct from the Parcel */ id = source.readInt(); name = source.readString(); } public void setId(int id) { this.id = id; } public void setName(String name) { this.name = name; } public int getId() { return this.id; } public String getName() { return this.name; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(id); dest.writeString(name); } public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { @Override public Customer createFromParcel(Parcel source) { return new Customer(source); } @Override public Customer[] newArray(int size) { return new Customer[size]; // TODO Auto-generated method stub } }; @Override public String toString() { return this.name; } } </code></pre> <p>But the auto suggest box does not filter correctly. for eg; if i type <code>an</code> in the test box customers starting with <code>br</code> are showing up!</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.
 

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