我試圖創建微調列表對話框,但我有錯誤「ArrayAdapter需要的資源ID是一個TextView」我創造了我俗適配器,它ArrayAdapter需要的資源ID是一個TextView在微調
public class OrderTypeAdapter extends ArrayAdapter<String> {
private final Context context;
private final List<String> values;
private class ResourseHolder{
protected TextView text;
}
public OrderTypeAdapter(Context context, List<String> values) {
super(context, R.layout.item_list_dialog,values);
this.context = context;
this.values = values;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View rowView;
if(convertView == null){
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
rowView = inflater.inflate(R.layout.item_list_dialog,parent,false);
ResourseHolder holder = new ResourseHolder();
holder.text = (TextView) rowView.findViewById(R.id.ild_main_text_view);
rowView.setTag(holder);
} else {
rowView = convertView;
}
ResourseHolder holder = (ResourseHolder) rowView.getTag();
holder.text.setText(values.get(position));
return rowView;
}
項目
}
XML代碼
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/ild_main_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
我本身牛逼Addapter通過非標準方式
OrderTypeAdapter adapter =new OrderTypeAdapter(getApplicationContext(),
Convert.toList(searchParam.getOrderTypes()));
orderTypeSpinner.setAdapter(adapter);
以微調器當我點擊微調作秀對話框我的應用程序崩潰,但是當我試圖用ArrayAdapter一切都OK。這裏有什麼問題 ?
顯示以及 –