listview - View List - Android Studio = Navigation Drawer Layout -
i beginner in android studio , need help. i'm trying make app on navigation drawer layout. so, found tutorial how specific layout when click on in navigation drawer menu
https://www.youtube.com/watch?v=ju837bqobfg&list=plqic834sj9lcamgq8jhpsrqpd9nfnjg0q
works perfect!
just want make viewlist in 1 layout of them i'm refering main navigation menu found next tutorial (http://www.viralandroid.com/2016/04/start-new-activity-from-android-listview-onitem-clicked.html).
i tried apply listview tutorial on brand-new project , works perfectly! problem when want apply project have used navigation on specific layouts fragments. says there duplication.
here mainactivity:
package com.example.martin.ultimateenglish; import android.os.bundle; import android.support.design.widget.floatingactionbutton; import android.support.design.widget.snackbar; import android.view.view; import android.support.design.widget.navigationview; import android.support.v4.view.gravitycompat; import android.support.v4.widget.drawerlayout; import android.support.v7.app.actionbardrawertoggle; import android.support.v7.app.appcompatactivity; import android.support.v7.widget.toolbar; import android.view.menu; import android.view.menuitem; public class mainactivity extends appcompatactivity implements navigationview.onnavigationitemselectedlistener { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); floatingactionbutton fab = (floatingactionbutton) findviewbyid(r.id.fab); fab.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { snackbar.make(view, "replace own action", snackbar.length_long) .setaction("action", null).show(); } }); drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout); actionbardrawertoggle toggle = new actionbardrawertoggle( this, drawer, toolbar, r.string.navigation_drawer_open, r.string.navigation_drawer_close); drawer.setdrawerlistener(toggle); toggle.syncstate(); navigationview navigationview = (navigationview) findviewbyid(r.id.nav_view); navigationview.setnavigationitemselectedlistener(this); } @override public void onbackpressed() { drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout); if (drawer.isdraweropen(gravitycompat.start)) { drawer.closedrawer(gravitycompat.start); } else { super.onbackpressed(); } } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify parent activity in androidmanifest.xml. int id = item.getitemid(); //noinspection simplifiableifstatement if (id == r.id.action_settings) { return true; } return super.onoptionsitemselected(item); } @suppresswarnings("statementwithemptybody") @override public boolean onnavigationitemselected(menuitem item) { // handle navigation view item clicks here. int id = item.getitemid(); if (id == r.id.list) { getfragmentmanager().begintransaction() .replace(r.id.content_frame , new first_layout()) .commit(); } else if (id == r.id.nav_changelog) { getfragmentmanager().begintransaction() .replace(r.id.content_frame , new changelog()) .commit(); } drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout); drawer.closedrawer(gravitycompat.start); return true; } }
could me? seems can't use name of class more once make 2 tutorials unbelieveable hard me now! want have navigation drawer layout menu items refering specific layouts want apply viewlist.
thank every advice or answer.
martin u.
Comments
Post a Comment