2012-11-12 17 views
8

डायलॉग पॉप-अप here पर स्थित है।ऑटोकंपलेटटेक्स्टव्यू ड्रॉप डाउन ऊंचाई डायलॉग पॉपअप

पॉप-अप व्यू के अंत में ऑटोकंपलेट परिणाम कैसे बंद होते हैं here है।

मैं चाहता हूं कि परिणामों को मूल दृश्य में संवाद के दृष्टिकोण से पहले छोड़ दें। अगर मैं ऐसा नहीं कर सकता तो मैं ऑटोकंपलेट को दो परिणामों को सीमित करने के परिणामों को सीमित करना चाहता हूं।

यह पॉपअप मेनू के लिए मेरे क्लिक श्रोता में है।

addDialog.setContentView(R.layout.shoppinglistadd); 

/**Capture the AutoCompleteTextView widget*/ 
final AutoCompleteTextView autoCompleteTV 
    = (AutoCompleteTextView) addDialog.findViewById(R.id.productEnteredShop); 
/**Fills the autocomplete with possibilities*/ 
String[] acArray = getResources().getStringArray(R.array.completeFoodsList); 
/**Create a new ArrayAdapter and bind shoppinglistitem.xml to each list item*/ 
ArrayAdapter<String> autoCompleteAdapter 
    = new ArrayAdapter<String>(ShoppingList.this, R.layout.shoppinglistitem, acArray); 
/**Associate the adapter with textView*/ 
autoCompleteTV.setAdapter(autoCompleteAdapter); 

उत्तर

3

आइटम भाग की सीमित संख्या के लिए: आप getCount()ArrayAdapter की ओवरराइड कर सकते हैं:

@Override 
public int getCount() { 
    return Math.min(2,super.getCount()); 
} 

यह भी छानने के लिए काम करता है।

+1

मुझे और स्पष्ट होना चाहिए था। मैं कुल परिणामों को 2 तक सीमित करने की तलाश नहीं कर रहा हूं। मैं बाकी की स्क्रॉलिंग के साथ दो बार एक बार दिखाए गए परिणामों की अधिकतम मात्रा को सीमित करना चाहता हूं। –

+0

हाँ, यह वह नहीं है जो वह पूछ रहा था। यह सिर्फ परिणाम संख्या को सीमित करता है। –

6

यहां तक ​​कि आप एक्सएमएल में AutoCompleteTextView विजेट लिए ड्रॉप-डाउन की ऊंचाई सीमा के लिए इस विधि को लागू करना चाहिए इस परिवर्तन को लागू:

android:dropDownHeight="size" 

या में कोडिंग के माध्यम से:

autoCompletetxtView.setDropDownHeight(int); 

आशा इस मदद करते हैं।

संबंधित मुद्दे