You do not have a listview in the layout that you inflate for the adapter
String matrix_id = ((ListView) view.findViewById(R.id.list)).getText()
.toString();
Hence the above initialization gives you NullpointerExcpetion
.
Guess work:
I can guess from the previous question that i answered of yours (ClassCastException: android.widget.TextView cannot be cast to android.widget.ListView). You have TextView's for the layout that you inflate in your adapter with ids R.id.matrix_id
and R.id.name
. But to confirm you can post your adapter code.
Copying from your previous question
ListAdapter adapter = new SimpleAdapter(
getActivity(), subjectList,
R.layout.all_subject, new String[] { TAG_MATRIX_ID,
TAG_NAME},
new int[] { R.id.matrix_id, R.id.name });
You can use getTag
and setTag
to avoid initialization of views again as suggested by laalto or
String matrix_id = ((TextView) view.findViewById(R.id.matrix_id)).getText()
.toString();
String name = ((TextView) view.findViewById(R.id.name)).getText()
.toString();