本篇文章为大家展示了在android项目中使用SwipeRefreshLayout组件实现下拉小球式刷新功能,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
创新互联公司是一家专注于网站设计制作、成都做网站与策划设计,解放网站建设哪家好?创新互联公司做网站,专注于网站建设10余年,网设计领域的专业建站公司;建站业务涵盖:解放等地区。解放做网站价格咨询:028-86922220
swiperefreshlayout实现下拉小球式的刷新,供大家参考,具体内容如下
布局文件:
<?xml version="1.0" encoding="utf-8"?>
MainActivity:
public class MainActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener{ private static final int REFRESH_STATUS =0; private ListView myListView; private SwipeRefreshLayout mySwipeRefreshLayout; private ArrayAdapterlistAdapter; private List listIDE = new ArrayList (Arrays.asList("Visual Studio", "Android Studio", "Eclipse", "Xcode")); private Handler refreshHandler = new Handler() { public void handleMessage(android.os.Message msg) { switch (msg.what) { case REFRESH_STATUS: listIDE.removeAll(listIDE); listIDE.addAll(Arrays.asList("C#", "Java", "C++","Object-C")); listAdapter.notifyDataSetChanged(); mySwipeRefreshLayout.setRefreshing(false); break; } }; }; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); myListView = (ListView) findViewById(R.id.listView); mySwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout); mySwipeRefreshLayout.setOnRefreshListener(this); mySwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); listAdapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1,listIDE); myListView.setAdapter(listAdapter); } @Override public void onRefresh() { refreshHandler.sendEmptyMessageDelayed(REFRESH_STATUS, 1500); } }
效果图:
上述内容就是在android项目中使用SwipeRefreshLayout组件实现下拉小球式刷新功能,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注创新互联行业资讯频道。