An example of multi-interface switching for Android learning notes

Source: Internet
Author: User

Used VB, vc# friends know that in VB or vc# in the window (interface) to switch is easy

For example, in VB, C #:

There are Fom1, Form2, FORM3, if you want to switch.

Form1.show ()

Form2.show ()

Quite simply, it was really "difficult" to do so in Android. You have to use your brain.

Based on my previous programming experience, I offer a simple solution here.

The first step is to create a new project, such as "UITest".

The second step is to transform the code file of this project

Open the "Uitestactivity.java" file. Delete the inside part of the code.

Remove the Setcontentview line. This way, the program will not automatically main.xml the interface.

The third step to the interface packaging combination

1 XML interface files with a Java file

First we will main.xml this layout interface to "packaging"

So after packing is finished, we return to Uitestactivity.java this file

Make modifications

See no, is not very feel like VB or vc#. Oh

Step fourth Create a new XML interface (Phone.xml)

After the interface is well laid out, create a new class file Frmphone.java

Once this step is done, we go back to the main interface and add a "button" inside it.

When the button control is added, go to the Frmmain.java and bind the event for this button

Now test run to see. Click on "Open Frmphone" on the main screen to open the phone interface.

After clicking, the program jumps to the Phone.xml interface.

Now you can get back to the main interface by binding an "event" to the "Back" button.

Test to see if it is already free to jump directly in the interface. And much like VB or vc#.

Related Article

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.