0

我猜应该缺少配置,但找不到。按照我在主要活动上显示操作栏的更改。

1 - 为根活动扩展 ActionBarActivity。

public class MainActivity extends ActionBarActivity implements OnItemSelectedListener {

2 - 将 minsdkversion 更新为 11

<uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="18" />

3 - 添加支持库 android-support-v7-appcombat.jar

4 - 更改菜单 xml。

<?xml version="1.0" encoding="utf-8"?>
<menu
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:yourapp="http://schemas.android.com/apk/res-auto"
>
    <item
        android:id="@+id/action_aboutbox"
        android:orderInCategory="100"
        android:showAsAction="always"
        android:title="@string/action_aboutbox"/>
    <item
        android:id="@+id/action_exit"
        android:orderInCategory="100"
        android:showAsAction="always"
        android:title="@string/action_exit"/>

</menu>

以下是运行应用程序后的 logcat 日志。

10-17 01:38:18.174: D/AndroidRuntime(1814): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
10-17 01:38:18.174: D/AndroidRuntime(1814): CheckJNI is ON
10-17 01:38:18.253: D/dalvikvm(1814): Trying to load lib libjavacore.so 0x0
10-17 01:38:18.274: D/dalvikvm(1814): Added shared lib libjavacore.so 0x0
10-17 01:38:18.343: D/dalvikvm(1814): Trying to load lib libnativehelper.so 0x0
10-17 01:38:18.343: D/dalvikvm(1814): Added shared lib libnativehelper.so 0x0
10-17 01:38:18.504: E/cutils-trace(1814): Error opening trace file: No such file or directory (2)
10-17 01:38:19.464: D/AndroidRuntime(1814): Calling main entry com.android.commands.pm.Pm
10-17 01:38:19.504: D/AndroidRuntime(1814): Shutting down VM
10-17 01:38:19.504: D/dalvikvm(1814): Debugger has detached; object registry had 1 entries
10-17 01:38:20.974: D/AndroidRuntime(1825): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
10-17 01:38:20.974: D/AndroidRuntime(1825): CheckJNI is ON
10-17 01:38:21.044: D/dalvikvm(1825): Trying to load lib libjavacore.so 0x0
10-17 01:38:21.075: D/dalvikvm(1825): Added shared lib libjavacore.so 0x0
10-17 01:38:21.224: D/dalvikvm(1825): Trying to load lib libnativehelper.so 0x0
10-17 01:38:21.224: D/dalvikvm(1825): Added shared lib libnativehelper.so 0x0
10-17 01:38:21.364: E/cutils-trace(1825): Error opening trace file: No such file or directory (2)
10-17 01:38:22.224: D/AndroidRuntime(1825): Calling main entry com.android.commands.am.Am
10-17 01:38:22.244: D/dalvikvm(1825): Note: class Landroid/app/ActivityManagerNative; has 163 unimplemented (abstract) methods
10-17 01:38:22.284: I/ActivityManager(286): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=org.siteprice.googlepagerankchecker/.MainActivity} from pid 1825
10-17 01:38:22.314: W/WindowManager(286): Screenshot failure taking screenshot for (123x164) to layer 21005
10-17 01:38:22.384: D/AndroidRuntime(1825): Shutting down VM
10-17 01:38:22.384: D/jdwp(1825): Got wake-up signal, bailing out of select
10-17 01:38:22.384: D/dalvikvm(1825): Debugger has detached; object registry had 1 entries
10-17 01:38:24.334: I/Choreographer(1795): Skipped 46 frames!  The application may be doing too much work on its main thread.
10-17 01:38:24.544: D/dalvikvm(1795): GC_FOR_ALLOC freed 234K, 11% free 2785K/3100K, paused 42ms, total 80ms
10-17 01:38:25.233: I/Choreographer(1795): Skipped 127 frames!  The application may be doing too much work on its main thread.
10-17 01:38:25.594: I/ActivityManager(286): Displayed org.siteprice.googlepagerankchecker/.MainActivity: +3s246ms

有什么我应该做的吗?

4

1 回答 1

0

利用

yourapp:showAsAction="always"
于 2014-03-27T11:51:02.580 回答