Android requestFeature() must be called before adding content

E/AndroidRuntime( 408): android.util.AndroidRuntimeException: requestFeature() must be called before adding content E/AndroidRuntime( 408): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:172) E/AndroidRuntime( 408): at com.android.internal.app.AlertController.installContent(AlertController.java:198) E/AndroidRuntime( 408): at android.app.AlertDialog.onCreate(AlertDialog.java:251) E/AndroidRuntime( 408): at android.app.Dialog.dispatchOnCreate(Dialog.java:307) E/AndroidRuntime( 408): at android.app.Dialog.show(Dialog.java:225) E/AndroidRuntime( 408): at com.nt572.Test$1.onClick(Test.java:25) E/AndroidRuntime( 408): at android.view.View.performClick(View.java:2408) E/AndroidRuntime( 408): at android.view.View$PerformClick.run(View.java:8816) E/AndroidRuntime( 408): at android.os.Handler.handleCallback(Handler.java:587) E/AndroidRuntime( 408): at android.os.Handler.dispatchMessage(Handler.java:92) E/AndroidRuntime( 408): at android.os.Looper.loop(Looper.java:123) E/AndroidRuntime( 408): at android.app.ActivityThread.main(ActivityThread.java:4627) E/AndroidRuntime( 408): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 408): at java.lang.reflect.Method.invoke(Method.java:521) E/AndroidRuntime( 408): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) E/AndroidRuntime( 408): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) E/AndroidRuntime( 408): at dalvik.system.NativeStart.main(Native Method)

出现此问题是由于dialog.show()之前调用了dialog.setContentView()了,正确的应该是dialog.show()之后调用dialog.setContentView()

http://blog.csdn.net/huigezhang/article/details/6529322

相关推荐