gsb*_*gsb 26 android pull-to-refresh android-5.0-lollipop
我正在尝试在Android中实现pull-to-refresh.我知道除了SwipeRefreshLayoutLollipop的所有新设计的Google应用程序(如Drive(见附件))之外,我注意到拉出时视图中会出现一个新的刷新图标.我尝试在线查看,但徒劳无功.Android是否已将此作为Material Design的一部分发布?关于如何实现它的任何想法?
编辑:有些人已经指出这是如何实现拉动刷新的重复.这不是同一个问题.如果你正确地阅读了这个问题,你会看到它.

goR*_*Gon 19
详细指南可以在这里找到:http://antonioleiva.com/swiperefreshlayout/
另外对于ListView我建议在评论中阅读canChildScrollUp();)
我最喜欢这本指南,它很容易理解:https://www.bignerdranch.com/blog/implementing-swipe-to-refresh/
将以下内容添加到gradle:
compile 'com.android.support:support-v4:22.2.0'
添加滑动以刷新到您的布局 - 在swiperefreshlayout的中间放入listview或recyclerview:
    <ListView
        android:id="@+id/activity_main_listview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >
    </ListView>
</android.support.v4.widget.SwipeRefreshLayout>
在主代码的代码中添加:
public class MainActivity extends Activity {
ListView mListView;
SwipeRefreshLayout mSwipeRefreshLayout;
Adapter mAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.acivity_main);
  SwipeRefreshLayout mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.activity_main_swipe_refresh_layout);
  mListView = findViewById(R.id.activity_main_list_view);
  mListView.setAdapter(new ArrayAdapter<String>(){
  String[] fakeTweets = getResources().getStringArray(R.array.fake_tweets);
  mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, fakeTweets)
  listView.setAdapter(mAdapter);
});
}
}
别忘了调用mSwipeRefreshLayout.setRefreshing(false); 一旦你的清爽结束.
| 归档时间: | 
 | 
| 查看次数: | 19470 次 | 
| 最近记录: |