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的任何替代方法以及如何实现。
谢谢。
最佳答案
使用自定义适配器,如下所示:
Listview list = (Listview)findviewbyId(R.id.list);
SearchListAdapter adapter = new SearchListAdapter(this,
getActivity(), rowItems(your data to inflate in adapter));
lis.setAdapter(adapter);