开发者

Android: number of MenuItems in a row

anybody found an easy way to change the number of elements in a menu row?

I have 5 MenuItems. They are put in row 1 with two, and row 2 with three items.

Is there an easy way to make row 1 to have three items and row 2开发者_如何学Python to have two items?

Thanks! Llappall


You may want to try to play with the "order" of the menu items. It is a flag that can be specified. Alternatively you may group them to have them layed out properly. Try to check out this site: http://developer.android.com/guide/topics/ui/menus.html

@Override
public boolean onCreateOptionsMenu(Menu menu){
    super.onCreateOptionsMenu(menu);

    // Create an Intent that describes the requirements to fulfill, to be included
    // in our menu. The offering app must include a category value of Intent.CATEGORY_ALTERNATIVE.
    Intent intent = new Intent(null, dataUri);
    intent.addCategory(Intent.CATEGORY_ALTERNATIVE);

    // Search and populate the menu with acceptable offering applications.
    menu.addIntentOptions(
         R.id.intent_group,  // Menu group to which new items will be added
         0,      // Unique item ID (none)
         0,      // Order for the items (none)
         this.getComponentName(),   // The current Activity name
         null,   // Specific items to place first (none)
         intent, // Intent created above that describes our requirements
         0,      // Additional flags to control items (none)
         null);  // Array of MenuItems that correlate to specific items (none)

    return true;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜