Exception is : 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
Firstly, I’ve looked at several answers already, but this seems a little more specific.
I’m having real difficulty tracking the problem with a ListAdapter, the items dont display anything I know an exception is being thrown, because its being caught and I’m attempting to log it – however all the log says is
11-30 15:33:06.703: I/class fyp.proj.crud.DisplayPlacements$ListAdapter(400): String resource ID #0x7
the values I’m trying to put into the listitem are set, the rather crude sys.err proves this. it is also worth noting that the number of items in the list expands when I insert or delete data, its just not visible
code below.
/* 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;
}
This line could be the problem:
if getId is not returning a String the number is meant as resource id. Try: