android.support.v4.widget.SwipeRefreshLayout.setDistanceToTriggerSync()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(81)

本文整理了Java中android.support.v4.widget.SwipeRefreshLayout.setDistanceToTriggerSync()方法的一些代码示例,展示了SwipeRefreshLayout.setDistanceToTriggerSync()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SwipeRefreshLayout.setDistanceToTriggerSync()方法的具体详情如下:
包路径:android.support.v4.widget.SwipeRefreshLayout
类名称:SwipeRefreshLayout
方法名:setDistanceToTriggerSync

SwipeRefreshLayout.setDistanceToTriggerSync介绍

[英]Set the distance to trigger a sync in dips
[中]设置触发下倾同步的距离

代码示例

代码示例来源:origin: chuyangliu/tastysnake

private void initRefreshLayout(View v) {
  refreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.connect_swipe_layout);
  refreshLayout.setColorSchemeColors(getResources().getColor(R.color.colorPrimary));
  refreshLayout.setProgressBackgroundColorSchemeColor(Config.COLOR_MAP_BG);
  refreshLayout.setDistanceToTriggerSync(20);
  refreshLayout.setSize(SwipeRefreshLayout.DEFAULT);
  refreshLayout.setNestedScrollingEnabled(true);
  refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
    @Override
    public void onRefresh() {
      if (!manager.isEnabled()) {
        startConnect();
      } else {
        startDiscover();
      }
    }
  });
}

代码示例来源:origin: GitLqr/MaterialDesignDemo

private void setSwipeRefreshLayout() {
  //设置 SwipeRefreshLayout 的尺寸
  mSrl.setSize(SwipeRefreshLayout.LARGE);
  //设置 SwipeRefreshLayout 刷新时的颜色切换(可以有无数种)
  mSrl.setColorSchemeColors(Color.RED, Color.YELLOW, Color.GREEN);
  //设置 SwipeRefreshLayout 的背景色
  mSrl.setBackgroundColor(Color.GRAY);
  //设置 SwipeRefreshLayout 的下拉距离
  mSrl.setDistanceToTriggerSync(100);
  //设置 SwipeRefreshLayout 正在刷新监听
  mSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
    @Override
    public void onRefresh() {
      for (int i = 0; i < 10; i++) {
        mData.add(0, (++number) + "");
      }
      mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
          mHandler.sendEmptyMessage(0);
        }
      }, 3000);
    }
  });
}

代码示例来源:origin: stackoverflow.com

mListView.setAdapter(mStringAdapter);
mSwipeRefreshLayout.setOnRefreshListener(this);
mSwipeRefreshLayout.setDistanceToTriggerSync(30);
mSwipeRefreshLayout.setSize(SwipeRefreshLayout.DEFAULT);

代码示例来源:origin: wangjjj/TallyBook

@Override
protected void initEventAndData() {
  PieChartUtil.initPieChart(mChart);
  mChart.setOnChartValueSelectedListener(this);
  dataYear.setText(DateUtils.getCurYear("yyyy 年"));
  dataMonth.setText(DateUtils.date2Str(new Date(), "MM"));
  //改变加载显示的颜色
  swipe.setColorSchemeColors(getResources().getColor(R.color.text_red), getResources().getColor(R.color.text_red));
  //设置向下拉多少出现刷新
  swipe.setDistanceToTriggerSync(200);
  //设置刷新出现的位置
  swipe.setProgressViewEndTarget(false, 200);
  swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
    @Override
    public void onRefresh() {
      swipe.setRefreshing(false);
      PieChartUtil.setAnimate(mChart);
    }
  });
  rvList.setLayoutManager(new LinearLayoutManager(getActivity()));
  list = new ArrayList<>();
  adapter = new TallyTypeRankAdapter(getActivity(), list);
  rvList.setAdapter(adapter);
  setReportData();
}

代码示例来源:origin: wangjjj/TallyBook

@Override
protected void initEventAndData() {
  dataYear.setText(DateUtils.getCurYear("yyyy 年"));
  dataMonth.setText(DateUtils.date2Str(new Date(), "MM"));
  //改变加载显示的颜色
  swipe.setColorSchemeColors(getResources().getColor(R.color.text_red), getResources().getColor(R.color.text_red));
  //设置向下拉多少出现刷新
  swipe.setDistanceToTriggerSync(200);
  //设置刷新出现的位置
  swipe.setProgressViewEndTarget(false, 200);
  swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
    @Override
    public void onRefresh() {
      swipe.setRefreshing(false);
    }
  });
  rvList.setLayoutManager(new LinearLayoutManager(getActivity()));
  adapter = new TallyAccountAdapter(getActivity(), list);
  adapter.setmListener(new TallyAccountAdapter.OnItemClickListener() {
    @Override
    public void onItemClick(int position) {
    }
  });
  rvList.setAdapter(adapter);
  //test data---------------
  setTestData();
}

代码示例来源:origin: wangjjj/TallyBook

swipe.setDistanceToTriggerSync(200);

相关文章