1、Layout
<android.support.v4.widget.SwipeRefreshLayout android:id="@+id/id_swipe_ly" android:layout_width="match_parent" android:layout_height="match_parent" > <com.github.mikephil.charting.charts.LineChart android:id="@+id/chart1" android:layout_width="match_parent" android:layout_height="match_parent" /> </android.support.v4.widget.SwipeRefreshLayout>
2、初始化
/** * 下拉刷新SwipeRefreshLayout */ private SwipeRefreshLayout mswipeLayout; mswipeLayout =(SwipeRefreshLayout)findViewById(R.id.id_swipe_ly); mswipeLayout.setOnRefreshListener(this); mswipeLayout.setColorSchemeResources(android.R.color.holo_blue_light, android.R.color.holo_blue_light, android.R.color.holo_blue_light, android.R.color.holo_blue_light);
3、继承接口
implements OnChartValueSelectedListener ,SwipeRefreshLayout.OnRefreshListener @Override public void onRefresh() { mHandler.sendEmptyMessageDelayed(0, 1000); }