我在反应原生应用中使用react-navigation。切换到另一个屏幕时,我使用此命令this.props.navigation.navigate
离。 <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<com.xw.repo.BubbleSeekBar
android:id="@+id/bubbleSeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="8dp"
app:bsb_auto_adjust_section_mark="true"
app:bsb_bubble_color="@color/colorPrimary"
app:bsb_bubble_text_color="@color/colorAccent"
app:bsb_max="10"
app:bsb_min="0"
app:bsb_progress="0"
app:bsb_second_track_color="@color/colorPrimary"
app:bsb_section_count="10"
app:bsb_section_text_position="below_section_mark"
app:bsb_show_progress_in_float="false"
app:bsb_show_section_mark="true"
app:bsb_show_section_text="true"
app:bsb_show_thumb_text="false"
app:bsb_track_color="@color/colorAccent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="45dp"
android:layout_height="50dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="10dp"
android:src="@mipmap/ic_launcher"/>
<ImageView
android:layout_width="45dp"
android:layout_height="50dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:src="@mipmap/ic_launcher"/>
<ImageView
android:layout_width="45dp"
android:layout_height="50dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:src="@mipmap/ic_launcher"/>
<ImageView
android:layout_width="45dp"
android:layout_height="50dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:src="@mipmap/ic_launcher"/>
<ImageView
android:layout_width="45dp"
android:layout_height="50dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:src="@mipmap/ic_launcher"/>
<ImageView
android:layout_width="45dp"
android:layout_height="50dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:src="@mipmap/ic_launcher"/>
</LinearLayout>
它工作得很好但是如何限制回到过去的屏幕(手机的后退按钮)。
答案 0 :(得分:1)
尝试重置路线状态并使用'AddGradeLevelScreen'
对其进行初始化import { NavigationActions } from 'react-navigation';
const resetAction = NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'AddGradeLevelScreen'})
]
});
this.props.navigation.dispatch(resetAction);