0

由于android中AutoCompleteTextBox中建议文本的背景颜色和文本颜色相同,因此建议文本不可见,我的xml文件是:

            <AutoCompleteTextView
            android:id="@+id/autoCompleteTextView1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2.4"
            android:background="#ffffff"
            android:ems="10"
            android:textColor="#000000" >
            </AutoCompleteTextView>

我的清单文件是:

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="9" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >

我的java文件是:protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.patient_registration);

    // Get a reference to the AutoCompleteTextView in the layout
    AutoCompleteTextView textView = (AutoCompleteTextView)    findViewById(R.id.autoCompleteTextView1);
    // Get the string array
    String[] countries = { "jan", "fbe", "mar", "june", "kokok", "opopopo" };
    // Create the adapter and set it to the AutoCompleteTextView
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_1, countries);
    textView.setThreshold(1);

    textView.setAdapter(adapter);

}
4

1 回答 1

1

尝试使用 android.R.layout.simple_dropdown_item_1line 而不是 android.R.layout.simple_list_item_1 - 它对我有用。

于 2013-06-20T17:56:39.307 回答