Android 相对布局中的AutoCompleteTextView
我想在我的应用程序中实现自动完成EditText 我为我的AutoCompleteTextView准备了activity\u add\u customer.xml,如下所示Android 相对布局中的AutoCompleteTextView,android,arraylist,nullpointerexception,textview,autocompletetextview,Android,Arraylist,Nullpointerexception,Textview,Autocompletetextview,我想在我的应用程序中实现自动完成EditText 我为我的AutoCompleteTextView准备了activity\u add\u customer.xml,如下所示 <AutoCompleteTextView android:id="@+id/monthAuto" android:layout_width="match_parent" android:layout_height="wrap_content"
<AutoCompleteTextView
android:id="@+id/monthAuto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:hint="Select a Month"
android:completionThreshold="1"
android:completionHint="Select a Month"
android:textAlignment="center"/>
更改此行:
setContentView(R.layout.activity_add_customer);
对此
setContentView(R.layout.main);
同时尝试将创建适配器实例的行更改为:
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, MONTHS);
请发布错误日志GCAT addedMy布局是活动添加客户,但您在文章开头写道,您使用的是main.xml,而不是活动添加客户。小心点,你在打字。对不起。我编辑了这个问题。
setContentView(R.layout.main);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, MONTHS);