1. Are you ready for the Galaxy S20? Here is everything we know so far!

DrawerLayout

Discussion in 'Android Development' started by Matoid, Sep 24, 2019.

  1. Matoid

    Matoid Lurker
    Thread Starter

    Hello everyone, I try to make a side navigation bar but when I come on the activity, the app closes without producing errors, I do not understand
    I'm attaching you XML, and Java
    Thank you in advance !
    Code (Java):
    1. package com.example.appliproject;
    2.  
    3. import androidx.appcompat.app.AppCompatActivity;
    4. import android.os.Bundle;
    5.  
    6. public class MainActivity extends AppCompatActivity {
    7.     protected void onCreate(Bundle savedInstanceState) {
    8.         super.onCreate(savedInstanceState);
    9.         setContentView(R.layout.activity_main);
    10.     }
    11.  
    12. }
    Code (Text):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    3.     xmlns:app="http://schemas.android.com/apk/res-auto"
    4.     xmlns:tools="http://schemas.android.com/tools"
    5.     android:id="@+id/drawer_layout"
    6.     android:layout_width="match_parent"
    7.     android:layout_height="match_parent"
    8.     android:fitsSystemWindows="true"
    9.     tools:openDrawer="start">
    10.  
    11.     <com.google.android.material.navigation.NavigationView
    12.         android:id="@+id/nav_view"
    13.         android:layout_width="wrap_content"
    14.         android:layout_height="match_parent"
    15.         android:layout_gravity="start"
    16.         android:fitsSystemWindows="true"
    17.         />
    18.  
    19. </androidx.drawerlayout.widget.DrawerLayout>
     

    Advertisement

  2. wseng92

    wseng92 Android Enthusiast

    It works fine on my side.
     
    #2 wseng92, Sep 27, 2019
    Last edited: Sep 30, 2019
Loading...

Share This Page

Loading...