时间:2021-05-20
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); }}效果图:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
Android中SwipeRefreshLayout与ViewPager滑动事件冲突解决方法问题描述:开发中发现,SwipeRefreshLayout的下拉刷新
本文实例为大家分享了SwipeRefreshLayout下拉刷新源码,供大家参考,具体内容如下1.SwipeRefreshLayout是Google在suppo
本文实例为大家分享了Android自定义下拉刷新上拉加载的具体实现步骤,供大家参考,具体内容如下实现的方式是SwipeRefreshLayout+Recycle
SwipeRefreshLayout的功能就是可以让我们的界面在不动的情况下,下拉直接刷新废话不多说,效果图奉上:activity_listview布局文件Ac
本文介绍了react-nativeListView下拉刷新上拉加载实现。分享给大家,具体如下:先看效果图下拉刷新ReactNative提供了一个组件可以实现下拉