全新的android工作室项目尚未完成

时间:2014-09-08 07:02:42

标签: android

我刚开始使用Android Studio, 在项目创建时生成以下代码

package ongame.test;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;


public class TitleScreen extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.title_screen);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.title_screen, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

预览具有相对布局和文本字段 当我尝试使用模拟器运行代码时,会出现以下错误

09-08 06:52:06.641    1726-1726/ongame.test D/dalvikvm﹕ Not late-enabling CheckJNI (already on)
09-08 06:52:06.681    1726-1726/ongame.test W/ActivityThread﹕ Application ongame.test is waiting for the debugger on port 8100...
09-08 06:52:06.691    1726-1726/ongame.test I/System.out﹕ Sending WAIT chunk
09-08 06:52:07.201    1726-1732/ongame.test I/dalvikvm﹕ Debugger is active
09-08 06:52:07.321    1726-1726/ongame.test I/System.out﹕ Debugger has connected
09-08 06:52:07.321    1726-1726/ongame.test I/System.out﹕ waiting for debugger to settle...
09-08 06:52:07.531    1726-1726/ongame.test I/System.out﹕ waiting for debugger to settle...
09-08 06:52:07.741    1726-1726/ongame.test I/System.out﹕ waiting for debugger to settle...
09-08 06:52:07.951    1726-1726/ongame.test I/System.out﹕ waiting for debugger to settle...
09-08 06:52:08.161    1726-1726/ongame.test I/System.out﹕ waiting for debugger to settle...
09-08 06:52:08.371    1726-1726/ongame.test I/System.out﹕ waiting for debugger to settle...
09-08 06:52:08.581    1726-1726/ongame.test I/System.out﹕ waiting for debugger to settle...
09-08 06:52:08.791    1726-1726/ongame.test I/System.out﹕ waiting for debugger to settle...
09-08 06:52:09.001    1726-1726/ongame.test I/System.out﹕ waiting for debugger to settle...
09-08 06:52:09.211    1726-1726/ongame.test I/System.out﹕ waiting for debugger to settle...
09-08 06:52:09.421    1726-1726/ongame.test I/System.out﹕ waiting for debugger to settle...
09-08 06:52:09.631    1726-1726/ongame.test I/System.out﹕ waiting for debugger to settle...
09-08 06:52:09.841    1726-1726/ongame.test I/System.out﹕ waiting for debugger to settle...
09-08 06:52:10.051    1726-1726/ongame.test I/System.out﹕ debugger has settled (1340)
09-08 06:52:10.081    1726-1726/ongame.test D/AndroidRuntime﹕ Shutting down VM
09-08 06:52:10.081    1726-1726/ongame.test W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xb2e08ce8)
09-08 06:52:10.181    1726-1726/ongame.test E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: ongame.test, PID: 1726
    java.lang.RuntimeException: Unable to start activity ComponentInfo{ongame.test/ongame.test.TitleScreen}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
            at android.app.ActivityThread.access$800(ActivityThread.java:138)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5026)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
            at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
            at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
            at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
            at android.app.Activity.setContentView(Activity.java:1930)
            at ongame.test.TitleScreen.onCreate(TitleScreen.java:14)
            at android.app.Activity.performCreate(Activity.java:5242)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
            at android.app.ActivityThread.access$800(ActivityThread.java:138)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5026)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
            at dalvik.system.NativeStart.main(Native Method)

模拟器显示"不幸的是,TEST已停止" 看起来错误来自于super.onCreate(savedInstanceState)行; 但是当我使用eclipse时,它就是确切的线,并且有效。 我不知道错误是什么。 非常感谢。

0 个答案:

没有答案