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

Source: Internet
Author: User

Recently in the first line of code this book, there is an example of the activity life cycle, but I myself with the Mac mounted as running a problem, see log is android.util.AndroidRuntimeException: Requestfeature () must be called before adding content this error, from the Internet to find a half-day, finally found a solution, although not too understand the principle, but here to do a share it.

This is the code after the change.

1 protected void onCreate (Bundle savedinstancestate) {2        requestwindowfeature (window.feature_no_title); 3 4         Super . OnCreate (savedinstancestate); 5         Setcontentview (r.layout.dialog_layout); 6     }

Originally requestwindowfeature This method is in the second sentence, but did not match the content of the error, but do put this statement in the front to run, there is know why the great God can help me answer, thank you.

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.