标签:
NewsFragment展示新闻列表的Fragment NewsFragment类继承实现ResponseListener<LinkedList<NewsModel>>接口实现网络请求的响应回调
实现AdapterView.OnItemClickListener接口用于实现列表点击的监听
// 设置新闻
mList = (ListView) mViewGroup.findViewById(R.id.newsList);
// 设置新闻列表点击监听事件
mList.setOnItemClickListener(this);
ListView的item点击监听
public void setOnItemClickListener(AdapterView.OnItemClickListener listener) { throw new RuntimeException("Stub!"); }
在Fragment里面,先用LayoutInflater.inflate方法来加载layout布局的ViewGroup,然后再通过ViewGroup.findViewById来找到相关的组件。
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// 填充Fragment布局
ViewGroup mViewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_news, container, false);
// 设置进度条 mLoadingProgress = (RelativeLayout) mViewGroup.findViewById(R.id.progressView);
适配器刷新数据
mNewsList.addAll(result);
mAdapter.updateData(mNewsList);
public void updateData(LinkedList<NewsModel> dataList) {
this.newsList = dataList;
this.notifyDataSetChanged();
}
标签:
原文地址:http://www.cnblogs.com/xbx2015/p/4554272.html