Skip to main content
1 de 1
Sama
  • 177
  • 1
  • 19

Estimados encontré la respuesta, en primera instancia el gran problema es que en el XML navigation está por arriba de del webView, y eso no dejaba que se capturara la selección y despúes modifique los archivos de java que les comparto a continuación.

<?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/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">



<WebView
    android:id="@+id/webView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:layout_alignParentTop="true"
   />


<android.support.design.widget.BottomNavigationView
    android:id="@+id/navigationsuperior"
    android:layout_width="1dp"
    android:layout_height="1dp"
    android:layout_marginTop="400dp"
    android:layout_marginBottom="50dp"
    android:background="?android:attr/windowBackground"
    android:backgroundTint="#304769"
    app:itemIconTint="@android:color/darker_gray"
    app:itemTextColor="@android:color/darker_gray"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:menu="@menu/navigationsuperior" />


<android.support.design.widget.BottomNavigationView

    android:id="@+id/navigation"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:background="?android:attr/windowBackground"
    android:backgroundTint="#304769"
    android:layout_marginTop="450dp"
    app:itemIconTint="@android:color/darker_gray"
    app:itemTextColor="@android:color/darker_gray"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:menu="@menu/navigation" />




<!--<android.support.design.widget.BottomNavigationView
    android:backgroundTint="@color/colorPrimary"
    android:id="@+id/navigationinferior"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginBottom="0dp"
    android:background="?android:attr/windowBackground"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:menu="@menu/navigationinferior" /> -->

<android.support.design.widget.NavigationView
    android:id="@+id/activity_main_drawer"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:layout_marginBottom="120dp"
    android:layout_marginLeft="100dp"
    android:background="?android:attr/windowBackground"
    app:itemIconTint="@android:color/black"
    android:backgroundTint="#f2f2f2"
    app:itemTextColor="#304769"
    app:menu="@menu/activity_main_drawer"
    />

</android.support.v4.widget.DrawerLayout>

MainActivity.java

    private NavigationView.OnNavigationItemSelectedListener lOnNavigationItemSelectedListener //SE UTLIZA PARA EL MANU LATERAL
        = new NavigationView.OnNavigationItemSelectedListener() {



        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            // Handle navigation view item clicks here.
             //int id = menuItem.getItemId();
             int id = item.getItemId();
            System.out.println("INGRESó-->  ");
          

            if (id == 1) {
                // Handle the camera action
                System.out.println("INGRESó 1-->  ");
            } else if (id == 2) {
                System.out.println("INGRESó 2-->  ");
            } else if (id == 3) {
                System.out.println("INGRESó 3-->  ");
            } else if (id == 4) {
                System.out.println("INGRESó 4-->  ");
            } else if (id == 5) {
                System.out.println("INGRESó 5 -->  ");
            } else if (id == 6) {
                System.out.println("INGRESó 6 -->  ");
            }

            DrawerLayout drawer = (DrawerLayout) findViewById(R.id.container);
            drawer.closeDrawer(GravityCompat.START);
            return true;

        }
    };


private void addMenuItemInNavMenuDrawer() {   //se utilizara para poner en el menù lateral los vehiculos por usuario
    NavigationView navView = (NavigationView) findViewById(R.id.activity_main_drawer);

    Menu menulateral = navView.getMenu();

   Menu submenu = menulateral.addSubMenu("Vehículos asociados");

 //  menulateral.add(0, 1, 0, "automovil").setIcon(R.drawable.auto_icon).getItemId();
    submenu.add(1, 1, 0, "automovil").setIcon(R.drawable.auto_icon).getItemId();
    submenu.add(1, 2, 0, "Taxi").setIcon(R.drawable.taxi_icon).getItemId();
    submenu.add(1, 3, 0, "Camion").setIcon(R.drawable.camion_icon).getItemId();
    submenu.add(1, 4, 0, "Moto").setIcon(R.drawable.moto_icon).getItemId();

    /*  submenu.add("Automovil").setIcon(R.drawable.auto_icon).getItemId();
    submenu.add("Taxi").setIcon(R.drawable.taxi_icon).getItemId();
    submenu.add("Camión").setIcon(R.drawable.camion_icon).getItemId();
    submenu.add("Motocicleta").setIcon(R.drawable.moto_icon).getItemId();*/


    navView.invalidate();
};

   @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    NavigationView navigationlateral = (NavigationView) 
    findViewById(R.id.activity_main_drawer);
    



    navigationlateral.setNavigationItemSelectedListener
    (lOnNavigationItemSelectedListener);
    navigationlateral.setItemIconTintList(null);

    addMenuItemInNavMenuDrawer();
  }
Sama
  • 177
  • 1
  • 19