我不知道为什么我要将java.lang.NullPointerException
设置为autocomplete
。正是这个说法产生了这个异常:获取NullPointerException
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);
那么,无论'textView'是'null'还是'adapter'都是'null'。只是'System.out.println'他们找出来。 -1,因为这可以非常容易地自行调试。 – Doorknob
感谢您的帮助。是的,我在textview上得到了null,这是我通过helpDialog.findViewById解决的。 –