在我的應用程序中,我使用popupwindow充氣了自定義視圖。Android的充氣列表爲MultiAutoCompleteTextview(MultiAutocompleteTextview在彈出窗口內)
現在裏面有一個AutoCompleteTextview提供建議。
現在的問題是,只要我開始在AutoCompleteTextView中輸入文本,應用程序就會崩潰。
錯誤日誌: -
Unable to add window -- token [email protected] is not valid; is your activity running?
的問題正在添加在這裏: -
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder vh;
View view = convertView;
if (view == null) {
if (inflater == null)
inflater = LayoutInflater.from(parent.getContext()); // ISSUE
view = inflater.inflate(R.layout.chips_adapter,parent, false); // ISSUE
vh = new ViewHolder();
vh.tv = (TextView) view.findViewById(R.id.textView1);
view.setTag(vh);
} else {
vh = (ViewHolder) view.getTag();
}
vh.tv.setText(suggestions.get(position).getTitle());
return view;
}
我認爲錯誤是關於另一個充氣佈局頂部膨脹的佈局。
將活動的上下文傳遞給適配器並使用相同的上下文對象。 – SripadRaj
@SripadRaj使用mainactivity上下文嘗試 –