Problems with the Android learning process

Source: Internet
Author: User

1. Use an overlay on the activity layout to display the action bar, the first time the error message appears.

The error message is as follows: Java.lang.RuntimeException:Ubable to start Activity componentinfo (* * *. mainactivity): Android.util.AndroidRuntimeException:requestFeature () must be called before adding Content.

The following code is the code for the OnCreate method of Mainactivity,

protected void OnCreate (Bundle savedinstancestate) {

Super.oncreate (savedinstancestate);

Here the code is used to set the fragment

GetWindow (). Requestfeature (Window.feature_action_bar_overlay);


Setcontentview (R.layout.activity_main);
}

Causes and solutions:

The overlapping properties of the action Bar must be set before the activity is added. It is necessary to put the code with the Green View Code before the yellow background code, the more correct way, the green background of the code placed in this line of code (super.oncreate (savedinstancestate);).

Problems with the Android learning process

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.