Android 04.16

Source: Internet
Author: User

In the busy two days of Android learning process finally got some of their own satisfied with the harvest.

The first is to build Android project and then do some button and toast with a lot of work still to be done.

Let me begin by saying the steps that need to be done:

First you need to create a layout in the res file that belongs to your current activity (XML), code-ing, then load your layout in the Java file under your package file, and if you want to make a toast then look at the next code OK, The following code is a manual revision of the revision, there may be errors, please forgive me.

First, the start is to do the button.

1 <?XML version= "1.0" encoding= "Utf-8"?>2 <LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"3 Android:layout_width= "Wrap_content"4 Android:layout_height= "Wrap_content"5 android:orientation= "vertical" >6 7     <Button8         Android:id= "@+id/button"9 Adnroid:layout_width= "Match_parent"Ten Android:layout_height= "Match_parent" One Android:text= "button"text displayed on the//button A android:textsize= "20px"//Control text size -         />     -  the </LinearLayout>

After you have finished making the button, you should load your button into your layout and make a toast appear;

See this long package name, I said it was played for a long time to find out

 Packagecom.example.***;//* * * is the name of your projectImportandroid.app.Activity;ImportAndroid.os.Bundle;ImportAdnroid.widget.Button;ImportAndroid.widget.Toast;ImportAndroid.view.Window;ImportAndroid.view.View.onClickListener;ImportAndroid.view.View; Public classMyActivityextendsactivity{@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); //requestwindowfeature (Window.feature_no_title); //Show feature misspelled many times, check for a long time error, the role is to remove the title barSetcontentview (r.layout.firstlayout); Button Toast=(Button) Findviewbyid (R.id.button); Toast.setonclicklistener (NewOnclicklistener () {///This side needs to load a Android.view.View.OnClickListener package, @Override Public voidoncreat (View v) {//view requires Android.view.View package to be able to use Toast.maketext (myactivity. This, "Toast", Toast.length_short). Show (); //}});} 

Android 04.16

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.