English 中文(简体)
巴巴多斯行动把菜单项目碎。 将他们置于前沿
原标题:ActionBar fragment menu items. Putting them in front
  • 时间:2012-04-26 15:00:39
  •  标签:
  • android

I m 成功增加使用的碎片菜单。

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
{
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.additional_fragment_menu, menu);
}

以上增加的菜单包括1个菜单。 我需要做的是,把这一菜单放在所有其他现有物品前面,以便首先出现在行动区。 目前似乎已经结束。

(这是android:showAsAction=“always” 项目Im 加上)

我试图从方案上补充这一条,但门图西项目没有选择允许你指定一行和显示行动旗帜。

没有人有什么想法?

最佳回答

奥克·我以正确方向的一位点子从EvilDuck对我本人进行镇压。 而且dymmeh 你们可以这样做!

我需要使用的是<代码>InCategory和menuCategory。 安德森似乎忽略了<条码>。 如无<代码>menuCategory具体规定。

  • I specified the category of every single menu item in my app by setting the menuCategory attribute value to "system".
  • My base menu items (the ones that are loaded via the Activity) I had to set high orderInCategory numbers, such as 10, 11, 12, 13 etc.
  • When I then inflated and added the additional fragment menu xml with the same category and an orderInCategory value 1 it showed up as the first item.
问题回答

使用“Rodid:Category”特性处理菜单

I m not sure where you re getting that you can t set the showAsAction option or the icon programmatically ex:

public void onCreateOptionsMenu(Menu menu)
{
    menu.add(Menu.NONE,  /** group ID.. not really needed unless you re working with groups **/
              0,         /** this is the items ID (get this in onOptionsItemSelected to determine what was clicked) **/
              Menu.NONE, /** ORDER.. this is what you want to change **/
              "Cancel") /** title **/
              .setIcon(R.drawable.ic_menu_cancel)
              .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}

Docs:

set 露天行动:

http://developer.android.com/vis/android/view/MenuItem.html#setIcon%28int%29”rel=“nofollow”>setIcon(int resId)

所有这些都是正确的,在《意见》中仅使用一条线以下。

setHasOptionsMenu(true);




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...