【发布时间】:2021-05-01 07:58:24
【问题描述】:
这是我在 xml 文件根布局中的 activity_main.xml 是 SwipeRefreshLayout 并且我在 backpress 上实现了一个快餐栏,但显示一个在 id activity_main_swipe_refresh_layout 中调用的错误是不支持的,那么我该怎么办。
<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">
<....>
这是我的 java 代码
boolean doubleBackToExitPressedOnce = false;
@Override
public void onBackPressed() {
if (doubleBackToExitPressedOnce) {
super.onBackPressed();
return;
}
this.doubleBackToExitPressedOnce = true;
Snackbar.make(activity_main_swipe_refresh_layout, "Please click BACK again to exit", Snackbar.LENGTH_SHORT).show();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
doubleBackToExitPressedOnce=false;
}
}, 2000);
这一行显示错误
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.
【问题讨论】:
标签: java android android-studio android-layout