我不知道为什么java.lang.NullPointerException
在将适配器设置为autocomplete
. 正是这个语句产生了这个异常:
textView.setAdapter(adapter);
我在布局文件夹中有两个布局。
AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this);
helpBuilder.setTitle("Search Location");
LayoutInflater inflater = getLayoutInflater();
View PopupLayout = inflater.inflate(R.layout.custom_autocomplete, null);
helpBuilder.setView(PopupLayout);
AlertDialog helpDialog = helpBuilder.create();
helpDialog.show();
textView = (AutoCompleteTextView)findViewById(R.id.locationAutoCompleteTv);
adapter = new ArrayAdapter<String>(this,R.layout.item_list);
adapter.setNotifyOnChange(true);
textView.setAdapter(adapter);