Android page Switching

Source: Internet
Author: User

Modify strings. xml

 
<? XML version = "1.0" encoding = "UTF-8"?> <Resources> <string name = "layout1"> This is layout 1 </string> <string name = "layout2"> This is layout 2 </string> <string name =" app_name "> ex8_ui </string> </resources>

Create a new color. xml file and save the two color values in the Res/values directory)

 
<? XML version = "1.0" encoding = "UTF-8"?> <Resources> <color name = "black"> #000000 </color> <color name = "white"> # ffffffff </color> </resources>

Modify the main. xml layout and add a textview and a button

<? XML version = "1.0" encoding = "UTF-8"?> <Absolutelayoutandroid: layout_width = "fill_parent" Android: layout_height = "fill_parent" Android: Background = "@ color/Black" xmlns: Android = "http://schemas.android.com/apk/res/android"> <textviewandroid: id = "@ + ID/text1" Android: textsize = "24sp" Android: layout_width = "186px" Android: layout_height = "29px" Android: layout_x = "70px" Android: layout_y = "32px" Android: text = "@ string/layout1"> </textview> <buttonandroid: Id = "@ + ID/button1" Android: layout_width = "118px" Android: layout_height = "wrap_content" Android: layout_x = "100px" Android: layout_y = "82px" Android: TEXT = "go to layout2"> </button> </absolutelayout>

Create a new mylayout. xml layout file (put in the Res/layout directory) and add two views: textview and button.

<? XML version = "1.0" encoding = "UTF-8"?> <Absolutelayoutandroid: layout_width = "fill_parent" Android: layout_height = "fill_parent" Android: Background = "@ color/White" xmlns: Android = "http://schemas.android.com/apk/res/android"> <textviewandroid: id = "@ + ID/text2" Android: textsize = "24sp" Android: layout_width = "186px" Android: layout_height = "29px" Android: layout_x = "70px" Android: layout_y = "32px" Android: textcolor = "@ color/Black" Android: text = "@ string/layout2"> </textview> <buttonandroid: id = "@ + ID/button2" Android: layout_width = "118px" Android: layout_height = "wrap_content" Android: layout_x = "100px" Android: layout_y = "82px" Android: TEXT = "go to layout1"> </button> </absolutelayout>

Compile mainactivity. Java

/** To change this template, choose tools | templates * and open the template in the editor. */package Org. me. setcontentviewapp; import android. app. activity; import android. OS. bundle; import android. view. view; import android. widget. button;/*** @ author liaokecheng 

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.