我只是想给其他活动添加到我的选项菜单 我有我的应用程序,它显示为安卓:增加了选项菜单动态
public class OptionsMenuTesterActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@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,getIntent().getData());
intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
// Search for, and populate the menu with, acceptable offering applications.
menu.addIntentOptions(
Menu.CATEGORY_ALTERNATIVE, // Menu group
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 corrolate to specific items (none)
return true;
}
}
现在我已经创造了另一个简单的应用程序有一个活动的菜单定义和它的androidmaifest看起来如下
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.idg.test.dynamicoptionsmenu"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".DynamicOptionsMenuTesterActivity"
android:label="@string/app_name" >
<intent-filter label="test menu">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
</application>
</manifest>
我有两个应用程序启动。但是,当我点击第一个应用程序的菜单,我什么都看不到 你能帮我告诉我在这里失踪吗?