+ 1
How can we load url whenever any options is pressed from navigation drawer in android app using Android studio?
4 ответов
+ 2
Override the onNavigationItemSlected method.
than within that method create a switch case.
switch (item.getItemId()){
default:
//Than you can load your desired URL
break;
}
+ 2
So if you have successfully created a NavigationView in your app.
Than you can just fetch the I'd of your NavigationView and set those Navigation items on the listener.
NavigationView navigationView=findViewById(R.id.Your_navigationView);
navigationView.setOnNavigationItemSelected(new NavigationView.OnNavigationItemSelected(){
@Override
public void OnNavigationItemSelected(MenuItem Item){
//For all Items
switch (item.getItemId()){
default:
break;
}
});
0
I am using fragments so will this work in fragments?
0
And can you please elaborate this code?😃 Means by giving an example.