Android------basics 1

Source: Internet
Author: User

Yesterday, Qian Feng Company to our school for a week, by the way I also review the Android UI


Yesterday explained in detail the TextView and some of the activity's introduction

Look at the XML first:

<!--layout Arrange the build linearlayout linear layout in a straight line arrangement UI build Xmlns:android namespace equivalent to importandroid:layout_width width android:la  Yout_height Height Match_parent fills the parent component with the maximum value that can be used fill_parentandroid:orientation the arrangement of the build vertically: vertical level: Horizontal --><linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" android:id= "@+id/linearlayout1   "Android:layout_width=" match_parent "android:layout_height=" match_parent "android:orientation=" vertical "> <!--display text components android:text display text wrap_content the contents of the package can be fully displayed android:background= "#F00" background color #RGB 200DP and pixel None The off unit adapts to multiple screens, guaranteeing the same effect on different screens @ resource references are similar to R.     Class + Add will be judged before adding, if present, if present does not add, add the TextView1 Android:id identity UI component to the R class ID subclass if it does not exist. <textview android:id= "@+id/textview1" android:layout_width= "Fill_parent" android:layout_height = "Fill_parent" android:background= "#F00" android:textsize= "30DP" android:text= "@sTring/hello_world "/></linearlayout> 



The following controls are found in the main activity:


Package Com.example.test;import Android.app.activity;import Android.os.bundle;import android.view.menu;import Android.view.view;import android.widget.textview;/** * Activity * One of the four major formation * used to display the application interface, you can interact with the user * click, drag. * @author Licheng * */public class Mainactivity extends Activity {//method inherited from Activity//method called when activity creates a call//main@overri deprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);//Set content View//set interface for activity display Index//r.layout.activity_main//res/layout/activity_main.xml//ctrol+d Delete Row setcontentview (R.layout.activity_main); Find the Build View Textview=findviewbyid (R.ID.TEXTVIEW1); Forced type conversion TextView tv= (TextView) TextView;  Modify Content Settings Text Tv.settext ("hehe"); /** * Shortcut key: * 1. Ctrl+shift+o Guide Pack * 2. CTRL + 10,000 can shortcut key * 3. ALT +/code lift */} @Overridepublic Boolean Oncreateoptionsmenu (Menu menu) {//Inflate the menu; This adds items to the action Bar if it is present.getmenuinflater (). Inflate (R.menu.main, menu); return true;}}




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.