Я хотел бы, чтобы остановить тягу, чтобы обновить после задержки, так что я сделал это, но он не работает:Стоп тянуть, чтобы обновить после задержки
final SwipeRefreshLayout mSwipeRefreshLayout = (SwipeRefreshLayout) rootview.findViewById(R.id.activity_main_swipe_refresh_layout);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override public void onRefresh() {
new Handler().postDelayed(new Runnable() {
@Override public void run() {
mSwipeRefreshLayout.setRefreshing(false);
}
}, 2000);
}
});
}
Вот XML код я не знаю если это хорошо:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<android.support.v4.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/activity_main_swipe_refresh_layout"
>
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@id/android:list"
android:longClickable="true"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true" />
<TextView
android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textSize="30sp"
android:text="" />
<com.getbase.floatingactionbutton.AddFloatingActionButton
android:id="@+id/semi_transparent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_plusIconColor="@color/primaryTextColor"
fab:fab_colorNormal="@color/primaryColor"
fab:fab_colorPressed="@color/AccentColor"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView5"
android:height="200dp"
android:width="200dp"
android:visibility="gone"
android:textSize="22dp"
android:text="Vous n'avez aucun coffy commencez par en ajouter un en cliquant sur le bouton +"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
<WebView
android:layout_width="10dp"
android:layout_height="10dp"
android:id="@+id/webView3"
android:visibility="invisible"
android:layout_above="@+id/semi_transparent"
android:layout_centerHorizontal="true" />
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
я попробовал все, если кто-то найти решение, это будет невероятно
Мой Handler импорт:
import android.os.Handler;
да, но это в фрагменте, так что это немного отличается – ouya
Он по-прежнему не работает, не понимаю, что не так – ouya
вы можете разместить xml layout.It может помочь. – NamNH