带有后退按钮的xamarin.android页面导航
如何在xamarin.android中使用后退按钮导航到页面 我是新来的带有后退按钮的xamarin.android页面导航,xamarin.android,navigation,Xamarin.android,Navigation,如何在xamarin.android中使用后退按钮导航到页面 我是新来的 我已经看过了,但找不到“后退”按钮的选项。对于需要添加活动类的每个页面,我都有另一个问题?您的问题不清楚,但“后退”按钮有一个覆盖 public override void OnBackPressed() { base.OnBackPressed(); // will close open activity either closing the application or going t
我已经看过了,但找不到“后退”按钮的选项。对于需要添加活动类的每个页面,我都有另一个问题?您的问题不清楚,但“后退”按钮有一个覆盖
public override void OnBackPressed()
{
base.OnBackPressed(); // will close open activity either closing
the application or going to your previous activity
}
您可以将其添加到您的活动中,然后每当按下“后退”按钮时,都可以执行某些操作。base.OnBackPressed();将运行默认的后退按钮行为并关闭当前活动。我经常这样做是为了在离开页面时显示确认对话框,或者在背压时关闭片段
public override void OnBackPressed()
{
if (_isBlahFragmentOpen)
{
ShowActionDialogue("Close blah", "Are you sure you wish to cancel adding blah any changes made will be lost.", CloseDateFragment);
}
else
base.OnBackPressed();
}
应用程序中需要有AppCompat库: 首先,您需要添加工具栏 工具栏.axml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFF">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
.
.
.
</LinearLayout>
你可以找到一个例子来回答你的大部分问题
祝你好运
如果您的问题研究片段的第二部分有疑问,请回复。您希望在每页上都有滑动菜单还是后退按钮?@G.hakim just back button您是否正在使用xamarin.android或xamarin表单?xamarin.android。我在我的帖子中提到:|但是我在下一页中看不到后退按钮。那么我如何覆盖它的事件?你的应用程序是全屏的吗?我认为默认情况下向上滑动屏幕底部应该会显示后退按钮?您可以使用下面的行Window.DecorView.SystemUiVisibility(View.SystemUiFlagVisible)强制后退按钮可见代码>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFF">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
.
.
.
</LinearLayout>