I have a problem trying to press an item of navigation View
.
What I do is create the objects directly from the Activity Main
since the purpose is to bring data from an external database and be completed.
Now the inconvenience is the following, I create the objects but when I want to go through it and show me that it just pointed that object it seems that it does not point it, it is more points to a webview
that is in the background that brings a map of google maps
and I move the pointer so I think I'm doing wrong creation of objects.
Then I leave the part of the code where I work both the creation and reception of objects (it should be noted that the navigation View
believes it in the folder layout
but only has the main structure nothing else.).
Main_activity.xml
<?xml version="1.0" encoding="utf-8"?>
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<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:layout_marginBottom="120dp"
android:layout_marginLeft="100dp"
app:menu="@menu/activity_main_drawer"
app:itemIconTint="@android:color/black"
android:backgroundTint="#f2f2f2"
app:itemTextColor="#304769"
/>
<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" />
MainActivity.java
public NavigationView.OnNavigationItemSelectedListener LonNavigationItemSelectedListener;{ //SE UTLIZA PARA EL MANU LATERAL
LonNavigationItemSelectedListener = new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
// Handle navigation view item clicks here.
// int id = menuItem.getItemId();
int id = menuItem.getItemId();
/* if (id == R.id.nav_camera) {
// Handle the camera action
} else if (id == R.id.nav_gallery) {
} else if (id == R.id.nav_slideshow) {
} else if (id == R.id.nav_manage) {
} else if (id == R.id.nav_share) {
} else if (id == R.id.nav_send) {
}*/
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.nav_view);
Menu menu = navView.getMenu();
Menu submenu = menu.addSubMenu(1,1,1,"Vehículos asociados");
submenu.add(1,1,1,"Automovil").setIcon(R.drawable.auto_icon);
/* 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();
}