例外是: Resources.NotFoundException
11-30 17:38:17.843:I / class fyp.proj.crud.DisplayProjects $ ListAdapter(967):android.content.res.Resources $ NotFoundException:String resource ID#0x9
首先,我已经看了几个答案,但这似乎更具体一些。
我很难用ListAdapter跟踪问题,这些项目不显示任何我知道异常被抛出的东西,因为它被捕获并且我试图记录它 - 但是所有的日志说是
11-30 15:33:06.703:I / class fyp.proj.crud.DisplayPlacements $ ListAdapter(400):字符串资源ID#0x7
设置了我试图放入listitem的值,相当粗略的sys.err证明了这一点。值得注意的是,当我插入或删除数据时,列表中的项目数量会扩大,只是不可见
以下代码。
/* ListAdapter */
private class ListAdapter extends ArrayAdapter<Placement> {
private ArrayList<Placement> mList;
public ListAdapter(Context context, int textViewResourceId,
ArrayList<Placement> list) {
super(context, textViewResourceId, list);
this.mList = list;
}
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
try {
if (view == null) {
LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = vi.inflate(R.layout.list_item, null);
}
final Placement p = mList.get(position);
if (p != null) {
// setting list_item views
/* some error in here means that the items aren't being set */
System.err.println(p.getTitle() + " "
+ p.getId());
/*
* this sys.err gets the details sucessfully from the
* placement object
*/
((TextView) view.findViewById(R.id.tv_id)).setText(p
.getId());
((TextView) view.findViewById(R.id.tv_title)).setText(p
.getTitle());
((TextView) view.findViewById(R.id.tv_desc)).setText(p
.getDesc());
}
} catch (Exception e) {
Log.i(DisplayProjects.ListAdapter.class.toString(),
e.getMessage());
}
return view;
}