这个我完全不明白,我正在尝试显示一个没有这样标题的自定义对话框
d.setContentView(R.layout.incident_dialog_layout);
d.requestWindowFeature(Window.FEATURE_NO_TITLE);
这样做给了我一个错误
07-25 11:56:23.737: E/AndroidRuntime(15680): android.util.AndroidRuntimeException: requestFeature() must be called before adding content
07-25 11:56:23.737: E/AndroidRuntime(15680): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:215)
07-25 11:56:23.737: E/AndroidRuntime(15680): at android.app.Dialog.requestWindowFeature(Dialog.java:1031)
07-25 11:56:23.737: E/AndroidRuntime(15680): at ecm2.android.MainActivity.createNewDialog(MainActivity.java:1121)
07-25 11:56:23.737: E/AndroidRuntime(15680): at ecm2.android.MainActivity$ListViews.onListItemClick(MainActivity.java:614)
07-25 11:56:23.737: E/AndroidRuntime(15680): at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
07-25 11:56:23.737: E/AndroidRuntime(15680): at android.widget.AdapterView.performItemClick(AdapterView.java:298)
07-25 11:56:23.737: E/AndroidRuntime(15680): at android.widget.AbsListView.performItemClick(AbsListView.java:1086)
07-25 11:56:23.737: E/AndroidRuntime(15680): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2855)
07-25 11:56:23.737: E/AndroidRuntime(15680): at android.widget.AbsListView$1.run(AbsListView.java:3529)
07-25 11:56:23.737: E/AndroidRuntime(15680): at android.os.Handler.handleCallback(Handler.java:615)
07-25 11:56:23.737: E/AndroidRuntime(15680): at android.os.Handler.dispatchMessage(Handler.java:92)
07-25 11:56:23.737: E/AndroidRuntime(15680): at android.os.Looper.loop(Looper.java:137)
07-25 11:56:23.737: E/AndroidRuntime(15680): at android.app.ActivityThread.main(ActivityThread.java:4745)
07-25 11:56:23.737: E/AndroidRuntime(15680): at java.lang.reflect.Method.invokeNative(Native Method)
07-25 11:56:23.737: E/AndroidRuntime(15680): at java.lang.reflect.Method.invoke(Method.java:511)
07-25 11:56:23.737: E/AndroidRuntime(15680): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-25 11:56:23.737: E/AndroidRuntime(15680): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-25 11:56:23.737: E/AndroidRuntime(15680): at dalvik.system.NativeStart.main(Native Method)
好的,很简单,只需更改请求的位置即可。所以我然后把它改成这个
d.requestWindowFeature(Window.FEATURE_NO_TITLE);
d.setContentView(R.layout.incident_dialog_layout);
对话框一直有效,直到我返回并单击创建对话框的项目时开始新活动时出现此错误
07-25 11:51:19.182: E/AndroidRuntime(15376): android.util.AndroidRuntimeException: requestFeature() must be called before adding content
07-25 11:51:19.182: E/AndroidRuntime(15376): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:215)
07-25 11:51:19.182: E/AndroidRuntime(15376): at android.app.Dialog.requestWindowFeature(Dialog.java:1031)
07-25 11:51:19.182: E/AndroidRuntime(15376): at ecm2.android.MainActivity.createNewDialog(MainActivity.java:1120)
07-25 11:51:19.182: E/AndroidRuntime(15376): at ecm2.android.MainActivity$ListViews.onListItemClick(MainActivity.java:614)
07-25 11:51:19.182: E/AndroidRuntime(15376): at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
07-25 11:51:19.182: E/AndroidRuntime(15376): at android.widget.AdapterView.performItemClick(AdapterView.java:298)
07-25 11:51:19.182: E/AndroidRuntime(15376): at android.widget.AbsListView.performItemClick(AbsListView.java:1086)
07-25 11:51:19.182: E/AndroidRuntime(15376): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2855)
07-25 11:51:19.182: E/AndroidRuntime(15376): at android.widget.AbsListView$1.run(AbsListView.java:3529)
07-25 11:51:19.182: E/AndroidRuntime(15376): at android.os.Handler.handleCallback(Handler.java:615)
07-25 11:51:19.182: E/AndroidRuntime(15376): at android.os.Handler.dispatchMessage(Handler.java:92)
07-25 11:51:19.182: E/AndroidRuntime(15376): at android.os.Looper.loop(Looper.java:137)
07-25 11:51:19.182: E/AndroidRuntime(15376): at android.app.ActivityThread.main(ActivityThread.java:4745)
07-25 11:51:19.182: E/AndroidRuntime(15376): at java.lang.reflect.Method.invokeNative(Native Method)
07-25 11:51:19.182: E/AndroidRuntime(15376): at java.lang.reflect.Method.invoke(Method.java:511)
07-25 11:51:19.182: E/AndroidRuntime(15376): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-25 11:51:19.182: E/AndroidRuntime(15376): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-25 11:51:19.182: E/AndroidRuntime(15376): at dalvik.system.NativeStart.main(Native Method)
那么它想让我做什么,因为我在设置内容后无法拥有它,也不能在我发送内容之前拥有它??????