@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View view = inflater.inflate(R.layout.loadfragment, null); loadingLayout = (LinearLayout) view.findViewById(R.id.loadinglayout); loadedLayout = (LinearLayout) view.findViewById(R.id.loadedlayout); loadingListView = (ListView) view.findViewById(R.id.loadinglistview); loadedListView = (ListView) view.findViewById(R.id.loadedlistview); loadingNum = (TextView) view.findViewById(R.id.loadingnum); loadedNum = (TextView) view.findViewById(R.id.loadednum); loadingRecLayout = (LinearLayout) view.findViewById(R.id.loadingreclayout); loadedRecLayout = (LinearLayout) view.findViewById(R.id.loadedreclayout); noloadinghistory = (TextView) view.findViewById(R.id.noloadinghistory); noloadedhistory = (TextView) view.findViewById(R.id.noloadedhistory); loadingLayout.setOnClickListener(this); loadedLayout.setOnClickListener(this); // 实例化文件传输适配器 loadingAdapter = new FileTransferAdapter(getActivity()); loadedAdapter = new DoneFileAdapter(getActivity()); // 获取下载的文件列表 fileList = FileDbUtil.getInstance(getActivity()).queryFileLoadHistory(2, 0, "time asc"); doneFileList = FileDbUtil.getInstance(getActivity()).queryFileLoadHistory(2, 1, "time desc"); // 设置下载导航条文本 loadingNum.setText("正在上传(" + fileList.size() + ")"); loadedNum.setText("已上传(" + doneFileList.size() + ")"); loadingAdapter.setTransferredFileList(fileList); loadedAdapter.setDoneFileList(doneFileList); loadingListView.setAdapter(loadingAdapter); loadedListView.setAdapter(loadedAdapter); // 注册广播接收 myBroadcastReceiver = new MyReceiver(); IntentFilter filter = new IntentFilter(); filter.addAction(Common.ACTION_REFRESH); filter.addAction(Common.ACTION_REMOVELOAD); filter.addAction(Common.ACTION_COMPLETED); filter.addAction(Common.ACTION_COMPLETED); Log.e("opt", "注册广播接收"); getActivity().registerReceiver(myBroadcastReceiver, filter); return view; }
@Override public void handleMessage(Message msg) { // TODO Auto-generated method stub super.handleMessage(msg); loadingAdapter.notifyDataSetChanged(); }