I have an activity class that extends from FragmentActivity
as I am using DialogFragment
in it.
Earlier this class was extended from ListActivity
and there was no issues but when I extended it from FragmentActivity
when the requirement of DialogFragment
arrive the method setListAdapter
becomes unavaible.
I want to know that how can I use the method setListAdapter
while extending my class from FragmentActivity
public class Main extends FragmentActivity{
…
…
private class fetchStudentInfo extends AsyncTask<String, Void, List<mStudentInfo>> {
@Override
protected List<mStudentInfo> doInBackground(String... urls) {
…
}
public void onPostExecute(List<mStudentInfo> StudentInfoCollection) {
setListAdapter(new StudentInfoAdapter((Activity) mainAppContext, StudentInfoCollection));
}
}
}
For setting setAdapter you need a listView reference like this ,
public class Main extends FragmentActivity {
private ListView mListView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_layout_id);
mListView = (ListView)findViewById(R.id.list);
}
private class fetchStudentInfo extends AsyncTask<String, Void, List<mStudentInfo>> {
@Override
protected List<mStudentInfo> doInBackground(String... urls) {
…
}
public void onPostExecute(List<mStudentInfo> StudentInfoCollection) {
mListView.setListAdapter(new StudentInfoAdapter((Activity) mainAppContext, StudentInfoCollection));
}
}
}
And also you need layout file with a listview inside with id R.id.list .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.