private void setNewsList() { SimpleAdapter listAdapter = new SimpleAdapter( getActivity(), n_list, R.layout.news_list, new String[] {"newsTitle", "newsDate"}, new int[] {R.id.newsTitle, R.id.date}); jwc_listView.setAdapter(listAdapter); jwc_listView.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub if (NetWorkUtil.isNetworkAvailable(getActivity())) { GlobleData.NEWSDETAIL_URL = n_list.get(position).get("newsHref").toString(); GlobleData.NEWSTITLE = n_list.get(position).get("newsTitle").toString(); Intent intent = new Intent(getActivity(), JwcNewsDetailActivity.class); startActivity(intent); } else { Toast.makeText(getActivity(), "无网络连接", Toast.LENGTH_LONG).show(); } } }); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // inflater the layout view = inflater.inflate(R.layout.jwc_news_layout, null); // 取得屏幕尺寸大小 displayScreenSize(); jwc_listView = (MyListView) view.findViewById(R.id.jwc_listView); refreshFragment(); jwc_listView.setOnRefreshListener( new OnRefreshListener() { public void onRefresh() { RefreshTask rTask = new RefreshTask(); rTask.execute(1000); } }); return view; }