Android Study Notes 2-multi-interface switching

Source: Internet
Author: User

Anyone who has used VB and VC # knows that it is easy to switch the window (Interface) in VB or VC #.

For example, in VB and C:

There are fom1, form2, and form3, if you want to switch.

Form1.show ()

Form2.show ()

It was quite simple. At that time, in Android, it was very "difficult" to do so. You have to worry about it.

 

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

 

Step 1 create a project, such as "uitest ".

Step 2: Transform the code file of this project

Open the "uitestactivity. Java" file. Delete the code.

Delete the setcontentview line. In this case, the main. XML interface will not be automatically used by the program.

 

Step 3 package and combine the interface

One XML interface file works with one Java File

First, we will "Wrap" the layout Interface main. xml"

 

After packaging, we will return to the uitestactivity. Java file.

Modify

See no, is it like VB or VC. Haha

 

Step 4 Create an XML interface (phone. XML)

 

After the interface is laid out, create a class file frmphone. Java

 

After this step is completed, we will return to the main interface and add a [button] in it]

After the button control is added, go to frmmain. Java and bind the event to this button.

 

Run the test now. Click [open frmphone] on the main interface to open the phone interface.

After clicking, the program jumps to the phone. XML interface.

Now bind the return button with another event to return to the main interface.

Test to see if you can jump directly on the interface. And similar to VB or VC #.

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.