protected void onPostExecute(String file_url) {
// dismiss the dialog after getting all products
pDialog.dismiss();
// updating UI from Background Thread
getActivity().runOnUiThread(new Runnable() {
public void run() {
/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(
getActivity(), inboxList,
R.layout.inbox_list_item, new String[] { TAG_LINK, TAG_SUBJECT },
new int[] { R.id.link, R.id.subject });
// updating listview
lv.setListAdapter(adapter);
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(getActivity(),
"You clicked on feed "+position, Toast.LENGTH_LONG).show();
}
});
}
});
}
我试图在片段活动中获取列表视图。 此列表视图是从JSON对象解析的。 此代码以片段形式运行。但是,setlistadapter会出错。 setlistadapter的任何替代方案以及如何实现它。 谢谢。
答案 0 :(得分:1)
使用自定义适配器,如下所示:
Listview list = (Listview)findviewbyId(R.id.list);
SearchListAdapter adapter = new SearchListAdapter(this,
getActivity(), rowItems(your data to inflate in adapter));
lis.setAdapter(adapter);