Android--activity Practice

Source: Internet
Author: User

The androidmanifest.xml in manifests.

<?xml version= "1.0" encoding= "Utf-8"? ><manifest xmlns:android= "Http://schemas.android.com/apk/res/android" Package= "Com.example.chenshuai.test" > <Application Android:allowbackup= "true"Android:icon= "@mipmap/ic_launcher"Android:label= "@string/app_name"Android:supportsrtl= "true"Android:theme= "@style/apptheme" > <!--who started before <activity android:name= ".                Axtivity2 "> <intent-filter> <action android:name=" Android.intent.action.MAIN "/>        <category android:name= "Android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:name= ". Mainactivity "> <intent-filter> <action android:name=" Android.intent.action.MAIN "/&G                T <category android:name= "Android.intent.category.LAUNCHER"/> </intent-filter> </activity&    Gt </application></manifest>

New Layoutactivity.xml in Layout

<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "    android:layout_width=" Match_parent "    android:layout_height=" Match_parent "     Android:weightsum= "1" >    <!-- Match parent window  match_parent        Package Contents    wrap_content-    <textclock        android:layout_width= "Wrap_content"        android:layout_height = "Wrap_content"       android:text= "Good People"      /></linearlayout>

Layout in mainactivity

 PackageCom.hanqi.text3;Importandroid.app.Activity;ImportAndroid.os.Bundle;//inherited activity. Public classMainactivityextendsActivity {@Override//overwrite OnCreate () overriding the parent class    protected voidonCreate (Bundle savedinstancestate) {//Super Parent class//The method that called the parent class        Super. OnCreate (savedinstancestate); //to set the association of Java Code and layout files//ID value via r fileSetcontentview (R.layout.activity_main); }}

New Activity2 in Java

 Packagecom.example.chenshuai.test;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.util.Log;/*** Created by Chenshuai on 2016/3/16.*/ Public classAxtivity2extendsActivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (r.layout.layoutactivity); System.out.println ("This is the first activity I run."); //Output LogLOG.D ("Test", "Log output Information"); LOG.W ("Test", "Log output Information");//Warning BlueLOG.E ("Test", "Log output Information");//Eror RedLOG.I ("Test", "Log output Information"); LOG.V ("Test", "Log output Information"); }}

Android--activity Practice

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.