Android ActionBarActivity无效

时间:2013-10-17 05:20:46

标签: android android-actionbar

我猜应该丢失配置但是找不到它。 我的更改是在主要活动上显示操作栏。

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>

以下是运行app后的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

我有什么需要做的吗?

1 个答案:

答案 0 :(得分:0)

使用

yourapp:showAsAction="always"