3
在我的應用程序中,我必須點擊文本框才能顯示所有列表項。如何在自動填充文本框中顯示完整列表項?
我試過AutoCompleteTextView
沒有輸入文本,但它不工作。
Android中是否有任何其他小部件可以實現這種情況?
請給我建議。
感謝,
在我的應用程序中,我必須點擊文本框才能顯示所有列表項。如何在自動填充文本框中顯示完整列表項?
我試過AutoCompleteTextView
沒有輸入文本,但它不工作。
Android中是否有任何其他小部件可以實現這種情況?
請給我建議。
感謝,
<AutoCompleteTextView
android:id="@+id/autoCompleteTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="65dp"
android:ems="10" >
private AutoCompleteTextView actv;
actv = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1);
String[] xyzvalues= getResources().
getStringArray(R.array.list_of_xyzvalues);
ArrayAdapter adapter = new ArrayAdapter
(this,android.R.layout.simple_list_item_1,xyzvalues);
actv.setAdapter(adapter);
試試這在我的機器上工作..
Okay for AutoCompleteTextView, try this way :
In XML Layout:
<AutoCompleteTextView
android:id="@+id/autoCompleteTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="65dp"
android:ems="10" >
In MainActivity,
private AutoCompleteTextView actv;
actv = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1);
The next thing you need to do is to specify the list of suggestion items to be displayed. You can specify the list items as a string array in java or in strings.xml.
String[] xyzvalues= getResources().
getStringArray(R.array.list_of_xyzvalues);
ArrayAdapter adapter = new ArrayAdapter
(this,android.R.layout.simple_list_item_1,xyzvalues);
actv.setAdapter(adapter);
Hope this helps.
使用[微調](http://developer.android.com/guide/topics/ui/controls/ spinner.html)Android中的Widget顯示列表項的下拉列表 – Nambi