2 activity jumps, and the second activity shows a blank

Source: Internet
Author: User

Achieve title problem between Android's 2 activity jumps encountered.

This is achieved by clicking the button in activity a and jumping to activity B. However, in the process of running, after clicking the button, the program does not appear abnormal and error, but the layout in B is not displayed.

Part of the code in the first activity:

public class mainactivity extends activity {    button  Button;    public void oncreate (bundle savedinstancestate)  {         super.oncreate (savedinstancestate);         setcontentview (R.layout.main);                  button =  (Button)  findviewbyid (R.id.button);         button.setonclicklistener (New view.onclicklistener ()  {             public void onclick (View  V)  {                 intent intent = new intent (mainactivity.this,              &Nbsp;  otheractivity.class);                 startactivity (Intent);             }        });     }}


Take a look at the code in the second activity:

public class Tablelayoutactivity extends Activity {public void Oncreate (Bundle savedinstancestate) {SUPER.ONCR        Eate (savedinstancestate);    Setcontentview (r.layout.other_activity); }}

A careful comparison of 2 activity can be found in which the onCreate (bundle savedinstancestate) (--The first activity--) and OnCreate (bundle Savedinstancestate)(--The second activity--) has subtle differences in the position of the case. This is why the second activity layout does not display correctly. Should all use the first activity of the oncreate form is good!



2 activity jumps, and the second activity shows a blank

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.