关闭

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

24人阅读 评论(0) 收藏 举报
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();
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:537次
    • 积分:130
    • 等级:
    • 排名:千里之外
    • 原创:13篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章存档