gpt4 book ai didi

Android:连续的MenuItems数

转载 作者:行者123 更新时间:2023-11-30 04:51:25 24 4
gpt4 key购买 nike

有人找到更改菜单行中元素数量的简单方法吗?

我有 5 个菜单项。它们放在第 1 行有两个,第 2 行有 3 个项目。

有没有一种简单的方法可以让第 1 行有三个项目,第 2 行有两个项目?

谢谢!拉普尔

最佳答案

您可能想尝试使用菜单项的“顺序”。它是一个可以指定的标志。或者,您可以将它们分组以正确布置它们。尝试查看此站点: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;
}

关于Android:连续的MenuItems数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3209954/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com