hello,
I have written a custom ArrayAdapter for a ListActivity :
private class StepItemAdapter extends ArrayAdapter<Step> {
public StepItemAdapter(Context context, List<Step> objects) {
super(context, R.layout.step_list_item,
R.id.list_item_sb,
objects);
}
@Override
public View getView(final int pos, View convertView, ViewGroup
parent) {
View v = super.getView(pos, convertView, parent); //
will crash
here
// etc ...
}
}
On the "onCreate" method of the activity I tell the activity to use
this adapter with a list of object I get from somewhere else
("t.getSteps()") :
adapter = new StepItemAdapter(this, t.getSteps());
this.setListAdapter(adapter);
Everything works fine and the activity is displayed. But if I add a
new object to the list and tell the adapter to refresh the view I've
got an error :
t.getSteps().add(3, new Step());
adapter.notifyDataSetChanged();
The "getView" method of my adapter is called, which is ok since the
list view need to be updated, but I've got an exception on the call to
"super.getView(pos, convertView, parent)".
The stack trace :
java.lang.NullPointerException
at
android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:
355)
at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
at pkr.tm.activities.EditTemplateActivity
$StepItemAdapter.getView(EditTemplateActivity.java:145)
at
android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:
220)
at android.widget.AbsListView.obtainView(AbsListView.java:1294)
at android.widget.ListView.makeAndAddView(ListView.java:1727)
at android.widget.ListView.fillDown(ListView.java:652)
at android.widget.ListView.fillSpecific(ListView.java:1284)
at android.widget.ListView.layoutChildren(ListView.java:1558)
at android.widget.AbsListView.onLayout(AbsListView.java:1147)
...
Do you guy have any ideas of what is going on ??
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en