ActionBarSherlock Static Attachment Menu

I want to have a menu bar in the bottom of the action, and I use ActionBarSherlock in my application, and I found a “static application” -demo that adds a “toolbar” at the bottom ..

So, I tried to implement this as shown below:

public class ReadMailInbox extends Activity implements OnCreateOptionsMenuListener 
{
    ActionBarSherlock mSherlock = ActionBarSherlock.wrap(this);

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

        mSherlock.setContentView(R.layout.readmessage_layout);      
    }

    @Override
    public boolean onCreateOptionsMenu(android.view.Menu menu) {
        return mSherlock.dispatchCreateOptionsMenu(menu);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {

        menu.add("Refresh")
        .setIcon(android.R.drawable.ic_menu_rotate)
        .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        return true;
    }
}

But he appears at the top of the view, not at the bottom ...

Also, I would like to use the xml layout for the menu, instead of adding each menu button, since I want to use this for several actions ...

So how can I make it show below below?

+3
source share
1 answer
  • Use parameter splitActionBarWhenNarrowin AndroidManifest.xml:

    <activity android:name=".YourActivity" android:uiOptions="splitActionBarWhenNarrow" />
    
  • Override onCreateOptionsMenuas follows:

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        final MenuInflater inflater = getSupportMenuInflater();
        inflater.inflate(R.menu.activity_home, menu);
    
        return super.onCreateOptionsMenu(menu);
    }
    
+5

All Articles