我是 Android 新手,在我的程序中使用溢出菜单,
我需要知道几件事:
问题1:如何去除Options中多余的空格,例如:视频、电子邮件
问题 2:想要对 FirstActivity 隐藏 Activity Name 或 Application Name 和 ICON
在下面查看我的代码,
菜单> items.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/phone"
android:title="@string/phone"
android:icon="@drawable/phone"
android:showAsAction="ifRoom|withText"
/>
<item
android:id="@+id/computer"
android:title="@string/computer"
android:icon="@drawable/computer"
android:showAsAction="ifRoom|withText"
/>
<item
android:id="@+id/gamepad"
android:title="@string/gamepad"
android:icon="@drawable/gamepad"
android:showAsAction="ifRoom|withText"
/>
<item
android:id="@+id/camera"
android:title="@string/camera"
android:icon="@drawable/camera"
android:showAsAction="ifRoom|withText"
/>
<item
android:id="@+id/video"
android:title="@string/video"
android:icon="@drawable/video"
android:showAsAction="ifRoom|withText"
/>
<item
android:id="@+id/email"
android:title="@string/email"
android:icon="@drawable/email"
android:showAsAction="ifRoom|withText"
/>
</menu>
清单.xml:
<application
android:icon="@drawable/ic_launcher"
android:uiOptions="splitActionBarWhenNarrow"
android:allowBackup="true" >
<activity
android:name="com.sample.menu.HomeActivity"
android:label="Demo App"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.sample.menu.FirstActivity"
android:label="First Activity">
<intent-filter>
<action android:name="com.sample.menu.second" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
FirstActivity.java:
public class FirstActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.activity_first);
getOverflowMenu();
}