Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Snackbar在backpress Android Studio上的SwipeRefreshLayout中不起作用_Java_Android_Android Studio_Android Layout - Fatal编程技术网

Java Snackbar在backpress Android Studio上的SwipeRefreshLayout中不起作用

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

这是我的xml文件中的activity_main.xml根布局是SwiperFreshLayout,我在backpress上实现了一个snackbar,但显示id activity_main_swipe_refresh_布局中调用的错误不受支持,那么我该怎么办呢

<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.