ricardoalcocer / actionbarextras

Titanium Android Native Module that exposes ActionBar features not exposed by the Titanium SDK
MIT License
148 stars 61 forks source link

I can't manage I do add a side menu icon and set an eventlistener to it #87

Closed fabiomlferreira closed 9 years ago

fabiomlferreira commented 9 years ago

I need to finish my app til 31 of August, and at the moment my only problem is that I can't create a menu icon that opened my drawer.

I have an image (menu.png) and I want to put it no the actionbar on the left side. Like in your image. actionbar

How can I do it to integrate with viezel/NappDrawer? Please I only need a quick example. Please @ricardoalcocer I really appreciate your help...

ricardoalcocer commented 9 years ago

You could use NappDrawer, but the correct way would be like this: https://github.com/manumaticx/Ti.DrawerLayout-Demo-Alloy-App/blob/master/README.md

ricardoalcocer commented 9 years ago

If you're also targeting iOS, you might want to consider this widget: https://github.com/FokkeZB/nl.fokkezb.drawer/blob/master/README.md

manumaticx commented 9 years ago

Hi @invaderhd

you could do something like this

var abx = require('com.alcoapps.actionbarextras');
var NappDrawerModule = require('dk.napp.drawer');
var win = NappDrawerModule.createDrawer({
    // ...
});

win.addEventListener('open',function(e){
  var activity = win.getActivity();
  if (activity){
    var actionbar = activity.actionBar;
    actionbar.displayHomeAsUp = true;
    actionbar.onHomeIconItemSelected = function(){ mainWindow.toggleLeftWindow(); };
    abx.setHomeAsUpIcon("/images/menu.png");
  }
});
fabiomlferreira commented 9 years ago

@ricardoalcocer I'm using nl.fokkezb.drawer, when I start this project I choose the nl.fokkezb.drawer because I'm target android and iOS and I thought that will be simple to use the same module for both platforms.

@manumaticx with your code I get the icon but the onHomeIconItemSelected is never fired. I already have done this but don't manage any solution to fire a function when the home icon is tapped. Did you have other idea?

manumaticx commented 9 years ago

@invaderhd onHomeIconItemSelected works for me. Just tested with 4.1.0.GA and the above code

manumaticx commented 9 years ago

@invaderhd I hope you met your deadline ;) Can we close this issue?

fabiomlferreira commented 9 years ago

I don't manage put it to work but I use the sdk 3.5.1 to send the first version of the app then I will remake somethings and try to fix the issue