-1
我想在我的應用程序中使用列表視圖,我沒有正確編碼,但是當我運行該應用程序時,它會關閉。這裏是我的代碼:我的android應用程序關閉
setListAdapter(new MyAdapter(this, android.R.layout.simple_list_item_1,R.id.textView1,getResources().getStringArray(R.array.cities)));
}
適配器
private class MyAdapter extends ArrayAdapter<String>{
public MyAdapter(Context context, int resource, int textViewResourceId,
String[] string) {
super(context, resource, textViewResourceId, string);
// TODO Auto-generated constructor stub
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
LayoutInflater in=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row=in.inflate(R.layout.list_item, parent, false);
String[] items=getResources().getStringArray(R.array.cities);
TextView tv=(TextView) row.findViewById(R.id.textView1);
return super.getView(position, convertView, parent);
}
}
}
崩潰日誌請 –