2010-07-09 61 views
1

有人發現了一種簡單的方法來改變菜單行中的元素數量嗎?Android:連續的MenuItems的數量

我有5個MenuItems。他們被放在第一排兩個,第二排三個項目。

有沒有簡單的方法讓行1有三個項目和行2有兩個項目?

謝謝! Llappall

回答

1

你可能想嘗試玩菜單項的「順序」。這是一個可以指定的標誌。或者,您可以將他們分組,讓他們妥善安置。嘗試看看這個網站: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; 
}