swiperefreshlayout实现下拉小球式的刷新,供大家参考,具体内容如下
布局文件:
<?xml version="1.0" enCoding="utf-8"?><relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"xmlns:tools="http://schemas.androID.com/tools" androID:layout_wIDth="match_parent"androID:layout_height="match_parent"androID:paddingleft="@dimen/activity_horizontal_margin"androID:paddingRight="@dimen/activity_horizontal_margin"androID:paddingtop="@dimen/activity_vertical_margin"androID:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> <androID.support.v4.Widget.SwipeRefreshLayout androID:ID="@+ID/swipeRefreshLayout" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" > <ListVIEw androID:ID="@+ID/ListVIEw" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content"> </ListVIEw> </androID.support.v4.Widget.SwipeRefreshLayout></relativeLayout>
MainActivity:
public class MainActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener{private static final int REFRESH_STATUS =0;private ListVIEw myListVIEw;private SwipeRefreshLayout mySwipeRefreshLayout;private ArrayAdapter<String> listadapter;private List<String> ListIDE = new ArrayList<String>(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);}@OverrIDepublic voID onRefresh() { refreshHandler.sendEmptyMessageDelayed(REFRESH_STATUS,1500); }}
效果图:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程小技巧。
总结以上是内存溢出为你收集整理的android组件SwipeRefreshLayout下拉小球式刷新效果全部内容,希望文章能够帮你解决android组件SwipeRefreshLayout下拉小球式刷新效果所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)