0

Is it possible to add a submenu to the Home Icon? Or move a new Icon in front of the home icon? The SlidingMenu by https://github.com/jfeinstein10/SlidingMenu is a good example for what i try to accomplish, but without the fancy part, just a simple drop down on the left corner.

Something like that just for the homeicon!

enter image description here

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
luQ
  • 519
  • 1
  • 10
  • 25

2 Answers2

3

Please read this question here, How to add submenu items to ActionBar action in code?. I think it shows exactly what you need, submenu.

Actually, what you can do is remove the home action item by calling:

getSupportActionBar().setDisplayShowHomeEnabled(false);

If you want to replace it with a drop-down menu your best bet would be constructing a Spinner and using the action bar's custom view.

Spinner dropdown = new Spinner(this);
//TODO attach to an adapter of some sort
getSupportActionBar().setCustomView(dropdown);
getSupportActionBar().setDisplayShowCustomEnabled(true);
Community
  • 1
  • 1
Marko Niciforovic
  • 3,561
  • 2
  • 21
  • 28
  • Ok adding a submenu works fine, but how can i attach the submenu to the home icon or replace it? Or is it possible to allign new items to the left? – luQ Apr 03 '13 at 10:00
  • mm now when I think of it check my edited answer, I think its better approach – Marko Niciforovic Apr 03 '13 at 10:04
1

When the user touches the aplication icon, the system calls your activity's onOptionsItemSelected() method with the android.R.id.home ID. So you just need to override this method and do what you want to do:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            // app icon in action bar clicked;
            //Do your actions
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
JEY
  • 6,973
  • 1
  • 36
  • 51
  • Thx for the quick answer. But thats not excactly what i meant. I added a picture to my original post to make it clear. – luQ Apr 03 '13 at 09:44