I have a Material Drawer which is made automatically in Android Studio. How can I do that when a user clicks on a certain button, he is transferred to another window? reference code MainActivity
Closed due to the fact that the participants are off topic : ♦ , pavel , Bald , Streletz , user194374 Aug 15 '16 at 6:07 .
It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:
- “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - pavel, Bald, Streletz, Community Spirit
- If you use a template from Android Studio, then there seems to be a transition already implemented when you click on menu items. What exactly is your problem? - pavlofff
- Hello, here is my MainActivity code goo.gl/beJM0N . I need that when I click on a certain button in NavigationView, the necessary activation should be launched - nexus2014su
|
2 answers
`if (id == R.id.nav_camera) { //code @Override public void onClick(View v) { Intent intent = new Intent(v.getContext(), PutClassName.class); startActivityForResult(intent, 0); } } }`
|
- Hang up the click listener on the NavigationView.
- In it, depending on the id of the clicked element, launch the required activation / display a fragment.
- Close the drawer
|