2012-04-01 16 views
23

मैं AutoComplete विजेट का उपयोग कर रहा हूं। यह दो पात्रों की खोज के लिए ठीक काम करता है लेकिन एक चरित्र के लिए काम नहीं करता है। जब भी उपयोगकर्ता केवल एक वर्ण में प्रवेश करता है तब भी मैं काम पूरा करना चाहता हूं।स्वत: पूर्ण खोज एक चरित्र एंड्रॉइड पर

उदाहरण के लिए जब मैं "1" दर्ज करता हूं तो यह सभी सूची को "1" से शुरू करना चाहिए। अब यह दिखा रहा है कि उदाहरण के लिए 2 वर्णों के लिए सुझाव सूची "12" है।

कोड:

zip.setOnFocusChangeListener(new OnFocusChangeListener() { 

     @Override 
     public void onFocusChange(View v, boolean hasFocus) { 
      if (hasFocus) { 
       String url = "xxxxxxxxxxxxxxxxxxxxxxx"; 
       String from = "zip"; 
       new GetAutoComplete(url, from).execute();// getting list 

      } 
     } 
    }); 



ArrayAdapter<Integer> aa = new ArrayAdapter<Integer>(
       MyActivity.this, R.layout.list_item_of_zip, 
       zip_codes); 
      zip.setAdapter(aa); // zip = autocomplete widget and zip_codes = arrayList 
+0

कोड दोस्त अपडेट किया गया !! – Sunny

+0

मुझे समझ में नहीं आता कि गिनती 0 का मतलब क्या है, ऐसी कोई बात नहीं है। – Sunny

उत्तर

66

अपने completionThreshold सेट 1.

<AutoCompleteTextView 
    android:id="@+id/your_id" 
    android:layout_width="200dp" 
    android:layout_height="wrap_content" 
    android:completionThreshold="1" /> 

लिए या यह करने के लिए गतिशील रूप से mAutoCompleteTextView.setThreshold(1) का उपयोग करें।

http://developer.android.com/reference/android/widget/AutoCompleteTextView.html

7

के रूप में एक तो यह पहले अक्षर के बाद से शुरू होता है सीमा बनाता है। आप इसका उपयोग कर सकते हैं:

mAutoCompleteTextView.setThreshold(1); 
संबंधित मुद्दे