बनाने मैं एक AutoCompleteTextViewAutoCompleteTextView प्रदर्शित करता है 'android.database.sqlite.SQLiteCursor @' ... चयन
mComment = (AutoCompleteTextView) findViewById(R.id.comment);
Cursor cComments = myAdapter.getDistinctComments();
scaComments = new SimpleCursorAdapter(this,R.layout.auto_complete_item,cComments,new String[] {DBAdapter.KEY_LOG_COMMENT},new int[]{R.id.text1});
mComment.setAdapter(scaComments);
auto_complete_item.xml
के लिए एडाप्टर (SimpleCursorAdapter) स्थापित करने के लिए निम्न कोड का उपयोग कर रहा करने के बाद<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
और थी वास्तविक नियंत्रण
<AutoCompleteTextView
android:id="@+id/comment"
android:hint="@string/COMMENT"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="18dp"/>
घ के लिए एक्सएमएल है रोपडाउन सही तरीके से काम करता प्रतीत होता है, और वस्तुओं की एक सूची दिखाता है। जब मैं सूची से चयन करता हूं तो मुझे टेक्स्टव्यू में एक स्क्लाइट ऑब्जेक्ट ('android.database.sqlite.SQLiteCursor @' ...) मिलता है। कोई भी जानता है कि इसका कारण क्या होगा, या इसे कैसे हल करें?
धन्यवाद
ठीक है मैं OnItemClick घटना में हुक करने में सक्षम हूँ, लेकिन AutoCompleteTextView विजेट के TextView.setText() भाग इस बिंदु के बाद अद्यतन किया जाता है। OnItemSelected() ईवेंट कभी नहीं निकाल दिया जाता है, और डाउनडाउन आइटम पहली बार प्रदर्शित होने पर कुछ भी नहीं चुना जाता है() ईवेंट निकाल दिया जाता है।
mComment.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
SimpleCursorAdapter sca = (SimpleCursorAdapter) arg0.getAdapter();
String str = getSpinnerSelectedValue(sca,arg2,"comment");
TextView txt = (TextView) arg1;
txt.setText(str);
Toast.makeText(ctx, "onItemClick", Toast.LENGTH_SHORT).show();
}
});
mComment.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
Toast.makeText(ctx, "onItemSelected", Toast.LENGTH_SHORT).show();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
Toast.makeText(ctx, "onNothingSelected", Toast.LENGTH_SHORT).show();
}
});
किसी और के पास टेक्स्टव्यू के अद्यतन को ओवरराइड करने के बारे में कोई विचार है?
धन्यवाद
पैट्रिक
हाँ, आप सही हैं:
गतिविधि के अंदर मेरे विस्तारित वर्ग के रूप में लग रहा है। मैं बस स्पिनर से विकल्पों में से एक का चयन कर रहा हूं जो AutoCompleteTextView के हिस्से के रूप में बनाया गया है। चयन को संसाधित करने के लिए मैं कहां या कैसे कार्यशीलता को रोकता हूं; कंट्रोल पर getString() का उपयोग करें, इसे नियंत्रण के पाठ के रूप में सेट करने से पहले। मैं भी अपना एक्सएमएल जोड़ूंगा। – bugzy
"चयन को संसाधित करने के लिए मैं कहां या कैसे कार्यशीलता को रोकता हूं" - आप पहले से ही ऐसा कर रहे हैं। कहीं, आप टेक्स्ट व्यू पर 'setText()' को कॉल कर रहे हैं। उस कोड को संपादित करें। – CommonsWare
यह बात है ... मैं नहीं। यह AutoCompleteTextView विजेट का अंतर्निहित व्यवहार है जो AutoCompleteTextView विजेट के TextView भाग को पॉप्युलेट कर रहा है। – bugzy