求助!关于下拉列表判断数据加载问题

public class TwoFragment extends Fragment {
    // 标志fragment是否初始化完成
    private boolean isPrepared;
    private View view;
    private CircleRefreshLayout mRefreshLayout;
    private ListView mList;
    private ArrayAdapter<String> adapter;
    public boolean flag;
    private Timer timer;

    @Override
    public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) {
        if(view == null){
            view = inflater.inflate(R.layout.fragment_two , container , false);
            ButterKnife.inject(this, view);
            KLog.e("TAG" , "twoFragment--onCreateView");
            mRefreshLayout = (CircleRefreshLayout) view.findViewById(R.id.refresh_layout);
            mList = (ListView) view.findViewById(R.id.list);
            init();

        }
        return view;
    }
   private  void init(){
        String[] strs =  {
                "The",
                "Canvas",
        };
        timer = new Timer();
        adapter = new ArrayAdapter<String>(this.getActivity(), R.layout.list, strs);

        mRefreshLayout.setOnRefreshListener(
                new CircleRefreshLayout.OnCircleRefreshListener() {
                    @Override
                    public void refreshing() {
                        // do something when refresh starts
                        timer.schedule(new TimerTask() {
                            @Override
                            public void run() {
                                Log.d("flag", "run: "+flag);
                                try {
                                 Thread.sleep(4000);
                                }catch(Exception e) {
                                    e.printStackTrace();
                                }if (true){
                                    flag=true;
                                    Log.d("flag1", "refreshing: "+flag);
                                }
                            }
                        },1000);

                    }
                    @Override
                    public void completeRefresh() {
                        // do something when refresh complete
                        mList.setAdapter(adapter);
                    }
                });
        if (flag) {
           //refreshing()方法执行完后,必须执行该方法才能执行completeRefresh()
            mRefreshLayout.finishRefreshing();
        }

    }

}

用的是这个下拉列表https://github.com/tuesda/CircleRefreshLayout
请问如何在refreshing()方法执行完后执行mRefreshLayout.finishRefreshing();
阅读更多
想对作者说点什么? 我来说一句

我的源码

2007年10月01日 357KB 下载

下拉框选择事件动态加载echart数据

2017年01月22日 29.45MB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭