1

ドキュメントでは、

addIntentOptions (int groupId, int itemId, int order, ComponentName caller, 
    Intent[] specifics, Intent intent, int flags, MenuItem[] outSpecificItems)

を受け取る必要がありますgroupIdが、以下のコードでMenu.CATEGORY_ALTERNATIVEは groupId として を持っていますが、これはどういう意味ですか?? 何をしCATEGORY_ALTERNATIVEますか?

 menu.addIntentOptions(
                Menu.CATEGORY_ALTERNATIVE,  // Add the Intents as options in the alternatives group.
                Menu.NONE,                  // A unique item ID is not required.
                Menu.NONE,                  // The alternatives don't need to be in order.
                null,                       // The caller's name is not excluded from the group.
                specifics,                  // These specific options must appear first.
                intent,                     // These Intent objects map to the options in specifics.
                Menu.NONE,                  // No flags are required.
                items                       // The menu items generated from the specifics-to-
                                            // Intents mapping
            );
4

1 に答える 1

0

あなたのコードは \docs\resources\samples\NotePad に由来する可能性があります。メソッド menu.addIntentOptions の最初のパラメーターは、次のことを意味します。項目が属するグループ識別子。これは、バッチ状態変更のアイテムのグループを定義するためにも使用できます。

実際には、任意の int 値を指定できます。Menu.NONEはうまくいきます!しかし、それが示唆しているように、バッチ状態変更のアイテムのグループを定義するためにも使用できます。コードに従い、else 句の後続のコード行で

}else{
        // If the list is empty, removes any alternative actions from the menu
        menu.removeGroup(Menu.CATEGORY_ALTERNATIVE);
    }

また、グループ ID が以前に指定されている場合にのみ、バッチ状態変更を実行することはできません

于 2013-02-02T16:19:18.750 に答える