actvity_main_drawer.xmlWie kann ich den Listener so einstellen, dass er in der Navigationsleiste wechselt?
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<group android:checkableBehavior="single">
<item
android:id="@+id/nav1"
android:icon="@drawable/ic_lock_outline_black_24dp"
android:title="test1" />
<item
android:id="@+id/nav2"
android:icon="@drawable/ic_add_a_photo_black_24dp"
android:title="test2" />
<item
android:id="@+id/nav3"
android:icon="@drawable/ic_face_black_24dp"
android:title="test3" />
</group>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include layout="@layout/content_main" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
onoff_toggle.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:id="@+id/switch_layout"
android:layout_height="match_parent">
<android.support.v7.widget.SwitchCompat
android:id="@+id/drawer_switch"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:checked="false"
android:textOff="off"
android:textOn="on"
app:showText="true"/>
</LinearLayout>
dies ist mein Schalter in Code xml Menüpunkt Navigationsleiste
wie i Zuhörer einstellen
Was haben Sie bisher versucht? Wenn Sie Ihr Android Studio öffnen, wird ein Projekt mit Navigationsleiste angeboten. Wählen Sie das Projekt aus und rufen Sie standardmäßig die Listener ab. –