zoukankan      html  css  js  c++  java
  • requestFeature() must be called before adding content产生原因和解决办法

    03-24 01:07:31.504 2957-2957/com.santai.jrj E/AndroidRuntime: FATAL EXCEPTION: main

                                                                  Process: com.santai.jrj, PID: 2957

                                                                  android.util.AndroidRuntimeException: requestFeature() must be called before adding content

                                                                      at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:249)

                                                                      at com.android.internal.app.AlertController.installContent(AlertController.java:234)

                                                                      at android.app.AlertDialog.onCreate(AlertDialog.java:337)

     

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



    Caused by: Android.util.AndroidRuntimeException: requestFeature() must be called before adding content

    [html] view plain copy
    1. setContentView(R.layout.main);  
    2. requestWindowFeature(Window.FEATURE_NO_TITLE);   

     

    解决方法如下:顺序换一下

    [html] view plain copy
    1. requestWindowFeature(Window.FEATURE_NO_TITLE);   
    2.   
    3. setContentView(R.layout.main);  




  • 相关阅读:
    Codeforces 166E. Tetrahedron
    Codeforce 687A. NP-Hard Problem
    Codeforces 570C. Replacement
    Codeforces 554B. Ohana Cleans Up
    Codeforces 482A. Diverse Permutation
    Codeforces 431C. k-Tree
    Codeforces 750B. Spider Man
    Codeforces 463A. Caisa and Sugar
    Codeforces 701B. Cells Not Under Attack
    Codeforces 445A. DZY Loves Chessboard
  • 原文地址:https://www.cnblogs.com/jeffen/p/6611004.html
Copyright © 2011-2022 走看看