按照教程来的,它自己生成的框架竟然有问题!!!简直了。。。请大神解答!
代码如下:(MainActivity.java)
package com.example.hello1;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, 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);
}
}
Logcat报错如下:
09-25 13:00:43.170: D/AndroidRuntime(979): Shutting down VM
09-25 13:00:43.170: W/dalvikvm(979): threadid=1: thread exiting with uncaught exception (group=0xb4aa8d70)
09-25 13:00:43.190: E/AndroidRuntime(979): FATAL EXCEPTION: main
09-25 13:00:43.190: E/AndroidRuntime(979): Process: com.example.hello1, PID: 979
09-25 13:00:43.190: E/AndroidRuntime(979): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.hello1/com.example.hello1.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
09-25 13:00:43.190: E/AndroidRuntime(979): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
09-25 13:00:43.190: E/AndroidRuntime(979): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
09-25 13:00:43.190: E/AndroidRuntime(979): at android.app.ActivityThread.access$800(ActivityThread.java:138)
09-25 13:00:43.190: E/AndroidRuntime(979): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
09-25 13:00:43.190: E/AndroidRuntime(979): at android.os.Handler.dispatchMessage(Handler.java:102)
09-25 13:00:43.190: E/AndroidRuntime(979): at android.os.Looper.loop(Looper.java:136)
09-25 13:00:43.190: E/AndroidRuntime(979): at android.app.ActivityThread.main(ActivityThread.java:5026)
09-25 13:00:43.190: E/AndroidRuntime(979): at java.lang.reflect.Method.invokeNative(Native Method)
09-25 13:00:43.190: E/AndroidRuntime(979): at java.lang.reflect.Method.invoke(Method.java:515)
09-25 13:00:43.190: E/AndroidRuntime(979): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
09-25 13:00:43.190: E/AndroidRuntime(979): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
09-25 13:00:43.190: E/AndroidRuntime(979): at dalvik.system.NativeStart.main(Native Method)
09-25 13:00:43.190: E/AndroidRuntime(979): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
09-25 13:00:43.190: E/AndroidRuntime(979): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
09-25 13:00:43.190: E/AndroidRuntime(979): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
09-25 13:00:43.190: E/AndroidRuntime(979): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
09-25 13:00:43.190: E/AndroidRuntime(979): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
09-25 13:00:43.190: E/AndroidRuntime(979): at android.app.Activity.setContentView(Activity.java:1930)
09-25 13:00:43.190: E/AndroidRuntime(979): at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
09-25 13:00:43.190: E/AndroidRuntime(979): at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110)
09-25 13:00:43.190: E/AndroidRuntime(979): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
09-25 13:00:43.190: E/AndroidRuntime(979): at com.example.hello1.MainActivity.onCreate(MainActivity.java:15)
09-25 13:00:43.190: E/AndroidRuntime(979): at android.app.Activity.performCreate(Activity.java:5242)
09-25 13:00:43.190: E/AndroidRuntime(979): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
09-25 13:00:43.190: E/AndroidRuntime(979): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)