ActionBarDrawerToggle issue on Android -
well guys, i'm development private personal app job, i'm having unknown issue, i'm kind of lost this, not understanding happening, i'm trying setup simple actionbardrawertoggle, doesn't working, , it's showing , unset icon instead setted, please, can help me? couldn't go ahead if don't resolve first
public class mainactivity extends activity { private string[] titulos; private drawerlayout navdrawerlayout; private listview navlist; private arraylist<item_objct> navitms; private typedarray navicons; private actionbardrawertoggle mdrawertoggle; private charsequence mdrawertitle; private charsequence mtitle; navigationadapter navadapter; //implementacion del listview @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); //drawer layout navdrawerlayout = (drawerlayout) findviewbyid(r.id.drawer_layout); //lista navlist = (listview) findviewbyid(r.id.lista); //declaramos el header el caul sera el layout de header.xml view header = getlayoutinflater().inflate(r.layout.header, null); //establecemos header navlist.addheaderview(header); //tomamos listado de imgs desde drawable navicons = getresources().obtaintypedarray(r.array.navigation_iconos); //tomamos listado de titulos desde el string-array de los recursos @string/nav_options titulos = getresources().getstringarray(r.array.nav_options); //listado de titulos de barra de navegacion navitms = new arraylist<item_objct>(); //agregamos objetos item_objct al array //pedidos navitms.add(new item_objct(titulos[0], navicons.getresourceid(0, -1))); //gastos navitms.add(new item_objct(titulos[1], navicons.getresourceid(1, -1))); //productos navitms.add(new item_objct(titulos[2], navicons.getresourceid(2, -1))); //clientes navitms.add(new item_objct(titulos[3], navicons.getresourceid(3, -1))); //ganancias navitms.add(new item_objct(titulos[4], navicons.getresourceid(4, -1))); //capital navitms.add(new item_objct(titulos[5], navicons.getresourceid(5, -1))); //declaramos y seteamos nuestrp adaptador al cual le pasamos el array con los titulos navadapter= new navigationadapter(this,navitms); navlist.setadapter(navadapter); //siempre vamos mostrar el mismo titulo mtitle = mdrawertitle = gettitle(); // declaramos el mdrawertoggle y las imgs utilizar mdrawertoggle = new actionbardrawertoggle( this, /*host activity*/ navdrawerlayout, /*drawerlayout object*/ r.drawable.ic_drawer, /*icono de navegacion*/ r.string.app_name, /* nombre de aplicacion*/ r.string.hello_world /* "close drawer" description*/ ) { /** * called when drawer has settled in closed state */ public void ondrawerclosed(view view) { log.e("cerrado completo", "!!"); } /** * called when drawer has settled in open state */ public void ondraweropened(view drawerview) { log.e("apertura completa", "!!"); } }; //establecemos que mdrawertoggle declarado anteriormente sea el drawerlistener navdrawerlayout.setdrawerlistener(mdrawertoggle); //establecemos que el actionbar muestre el boton home getactionbar().setdisplayhomeasupenabled(true);
that main activity class, don't find asnwer why
i think forgot add together things:
1.-override next activity methods sync drawertoggle state:
@override protected void onpostcreate(bundle savedinstancestate) { super.onpostcreate(savedinstancestate); // sync toggle state after onrestoreinstancestate has occurred. mdrawertoggle.syncstate(); } @override public void onconfigurationchanged(configuration newconfig) { super.onconfigurationchanged(newconfig); mdrawertoggle.onconfigurationchanged(newconfig); }
2.- also, need tell actionbar home icon must enabled. phone call next in oncreate example:
getactionbar().setdisplayhomeasupenabled(true); getactionbar().sethomebuttonenabled(true);
i hope helps you.
if not help you, check:http://developer.android.com/training/implementing-navigation/nav-drawer.html guide
good luck
android
No comments:
Post a Comment