Autocomplete text in android? -


in application using auto-complete-text. when user types t shows three , two , fifty want show two , three not fifty. can 1 me solve problem.

string search[] = {"one","two","three","four","five","six","seven","fifty"};      arrayadapter<string> adp= new arrayadapter<string>(this,r.layout.searchtext, search);     search_item.setthreshold(1);     search_item.setadapter(adp); 

i don't think have create custom adapter. default functionality want. check this

here have array like:

private static final string[] countries = new string[] { "belgium",         "france", "france_", "italy", "germany", "spain","abcf","ffa","ffb","bff","aff" }; 

when search ff give me 2("ffa","ffb") suggestion not 4("ffa","ffb","bff","aff")

enter image description here

i have used in actionbar. can use in layout. because custom layout in actionbar.

public class testactivity extends activity {      /** called when activity first created. */     private static final string[] countries = new string[] { "belgium",         "france", "france_", "italy", "germany", "spain","abcf","ffa","ffb","bff","aff" };      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);          setcontentview(r.layout.activity_main);          actionbar actionbar = getactionbar();         actionbar.setdisplayhomeasupenabled(true);         actionbar.setdisplayshowcustomenabled(true);         // actionbar.setdisplayshowtitleenabled(false);         // actionbar.seticon(r.drawable.ic_action_search);          layoutinflater inflator = (layoutinflater)                 .getsystemservice(context.layout_inflater_service);         view v = inflator.inflate(r.layout.test, null);          actionbar.setcustomview(v);          arrayadapter<string> adapter = new arrayadapter<string>(this,                 android.r.layout.simple_dropdown_item_1line, countries);         autocompletetextview textview = (autocompletetextview) v                 .findviewbyid(r.id.edittext1);         textview.setadapter(adapter);      } } 

test.xml

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:gravity="center" >      <textview         android:id="@+id/textview1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="action bar:"         android:textappearance="?android:attr/textappearancemedium"         android:textcolor="#ffffff" />      <autocompletetextview         android:id="@+id/edittext1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:ems="10"         android:imeoptions="actionsearch"         android:inputtype="textautocomplete|textautocorrect"         android:textcolor="#ffffff" >          <requestfocus />     </autocompletetextview>  </linearlayout> 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -