Failed Using Listadapter In Extends Fragment
I trying to update the JSON data into ListView. It failed when using ListAdapter. Is fragment didnt allow that ? I insist want to use the extends Fragment. Is there any method on t
Solution 1:
You need to extend ListFramgent
. setListAdapter
is a method of ListFragment
.
No need to use runOnUiThread
. onPostExecute
is invoked on the ui thread.
Edit:
@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
ViewrootView= inflater.inflate(R.layout.fragment_schedule, container, false);
subjectList = newArrayList<HashMap<String, String>>();
myListView = (ListView) rootView.findViewById(R.id.textViewMatrix);
newLoadAllSubject().execute();
myListView.setOnItemClickListener(newOnItemClickListener() {
@OverridepublicvoidonItemClick(AdapterView<?> parent, View view,
int position, long id) {
Stringmatrix_id= ((TextView) view.findViewById(R.id.textViewMatrix)).getText()
.toString();
// Starting new intentIntentin=newIntent(getActivity().getApplicationContext(),
SingleSubject.class);
// sending matrix id to next activity
in.putExtra(TAG_MATRIX_ID, matrix_id);
// starting new activity and expecting some response back
startActivityForResult(in, 100);
}
});
return rootView;
}
Then
protectedvoidonPostExecute(String file_url) {
super.onPostExecute(file_url);
pDialog.dismiss();
ListAdapter adapter = newSimpleAdapter(
getActivity(), subjectList,
R.layout.all_subject, newString[] { TAG_MATRIX_ID,
TAG_NAME},
new int[] { R.id.matrix_id, R.id.name });
myListView.setAdapter(adapter);
}
Post a Comment for "Failed Using Listadapter In Extends Fragment"