1

So what i want to do, is to have that menu button that we all know, to be displayed in the top right corner.

And as I've searched online, I found that actionbar Sherlock kind of suites my needs.

Picture of how menu looks right now

As you can see from he pic, the code that I use, adds that darker blue part in my design (the one that I ilustrated in a red rectangle using my awesome paint skills), and i want that button that is a green circle, to be placed in the area where the green arrow (nice movie :D) points.

The only code that i used to display this is below, and it is taken from the Sherlock demos:

ActionMode mMode;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mMode = startActionMode(new AnActionModeOfEpicProportions());

}

private final class AnActionModeOfEpicProportions implements ActionMode.Callback {
        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            //Used to put dark icons on light action bar
     //       boolean isLight = SampleList.THEME == R.style.Theme_Sherlock_Light;

            menu.add("Feedback")
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

            menu.add("Share")
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

            menu.add("Preferences")
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

            menu.add("Refresh")
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

            return true;
        }

        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        @Override
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            Toast.makeText(AndroidMenu.this, "Got click: " + item, Toast.LENGTH_SHORT).show();
            mode.finish();
            return true;
        }

        @Override
        public void onDestroyActionMode(ActionMode mode) {
        }
    }

I can't seem to figure out where that design comes from (probably the Sherlock framework), and how can i modify it like I want...

Any ideas guys ?

EDIT:

The answer that I found is to use a different Sherlock Sample for my goal :

public class SubMenus extends SherlockActivity {
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {

        SubMenu subMenu1 = menu.addSubMenu("Action Item");
        subMenu1.add("Sample");
        subMenu1.add("Menu");
        subMenu1.add("Items");

        MenuItem subMenu1Item = subMenu1.getItem();
        subMenu1Item.setIcon(R.drawable.ic_title_share_default);
        subMenu1Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

        SubMenu subMenu2 = menu.addSubMenu("Overflow Item");
        subMenu2.add("These");
        subMenu2.add("Are");
        subMenu2.add("Sample");
        subMenu2.add("Items");

        MenuItem subMenu2Item = subMenu2.getItem();
        subMenu2Item.setIcon(R.drawable.ic_compose);

        return super.onCreateOptionsMenu(menu);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setTheme(SampleList.THEME); //Used for theme switching in samples
        super.onCreate(savedInstanceState);
        setContentView(R.layout.text);
        ((TextView)findViewById(R.id.text)).setText(R.string.submenus_content);
    }
Teshte
  • 624
  • 1
  • 7
  • 26
  • Just like you cannot change older versions menu to appear from above I've never heard about changing the position of that menu button. Btw +1 and we'll wait together for better answers :) – Cob013 Jun 15 '13 at 09:00
  • @Rob013 ok, but what i want is to be able to style that area in the red rectangle (the design as it is comes from sherlock). For example i want to delete that check mark from the left, and to put that text, "Previous Orders" instead. – Teshte Jun 15 '13 at 09:03
  • Have you tried this: http://stackoverflow.com/questions/10863080/building-actionmode-with-custom-layout-in-actionbarsherlock ? – Cob013 Jun 15 '13 at 09:25

1 Answers1

0

The best way to personalize such objects is to set a custom View on them. Perhaps you can inflate a custom layout which provides one TextView and a Button on the right, without the "Done" mark on the left.

This is a snippet of code from this

 LayoutInflater inflater = LayoutInflater.from(getSherlockActivity());
 View actionView = inflater.inflate(R.layout.actionmode, null);

 ActionMode am = getSherlockActivity().startActionMode(mActionModeCallback);
 am.setCustomView(actionView);
Community
  • 1
  • 1
Cob013
  • 1,057
  • 9
  • 22
  • unfortunately i could not make your solution work...anyway i tried a different approach in my goal to make a menu button, and used another sample from Android Sherlock.(as you can see in my edited initial post) – Teshte Jun 15 '13 at 15:22