ListViewを含む私のフラグメントの1つにSwipeRefreshLayout
を使用しています。Android Studioでリフレッシュスワイパーハンドラーを設定する
swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh);
swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
swipeLayout.setRefreshing(true);
view.refreshDrawableState();
swipeLayout.setRefreshing(false);
}
});
私はスワイプするたびにリストビューを更新するためにこれを行いますが、何も更新されません。
私のレイアウトは以下のように実装されます。
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/swipe_refresh"
android:background="@drawable/bg"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/match_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="255"/>
</android.support.v4.widget.SwipeRefreshLayout>
それが動作しないのはなぜ?
私は 'refreshDrawableState()'とは思っていません。そこにある 'Adapter'のデータセットを更新する必要があります。 –