Java Snackbar在backpress Android Studio上的SwipeRefreshLayout中不起作用
这是我的xml文件中的activity_main.xml根布局是SwiperFreshLayout,我在backpress上实现了一个snackbar,但显示id activity_main_swipe_refresh_布局中调用的错误不受支持,那么我该怎么办呢Java Snackbar在backpress Android Studio上的SwipeRefreshLayout中不起作用,java,android,android-studio,android-layout,Java,Android,Android Studio,Android Layout,这是我的xml文件中的activity_main.xml根布局是SwiperFreshLayout,我在backpress上实现了一个snackbar,但显示id activity_main_swipe_refresh_布局中调用的错误不受支持,那么我该怎么办呢 <androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/andro
<androidx.swiperefreshlayout.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:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/activity_main_swipe_refresh_layout"
android:background="@color/background"
tools:context=".CoronaTracker.CoronaTrackerActivity">
<....>
这行显示错误
Snackbar.make(activity_main_swipe_refresh_layout, "Please click BACK again to exit", Snackbar.LENGTH_SHORT).show();
activity_main_swipe_refresh_layout It is the root layout id of the my activity but stile not working.
SnackBar仅与CoordinatorLayout配合使用。
尝试使用CoordinatorLayout作为根元素否,但不能使用relativeLayout和LinerLayout,但不能使用SwipeRefreshLayout。将根视图设置为CoordinatorLayout或relativeLayout或LinerLayout,并将子视图设置为RefreshLayout。它工作得很好。
Snackbar.make(activity_main_swipe_refresh_layout, "Please click BACK again to exit", Snackbar.LENGTH_SHORT).show();
activity_main_swipe_refresh_layout It is the root layout id of the my activity but stile not working.