Android from zero single row first stage button display HelloWorld

Source: Internet
Author: User

Cheer up ~ I am qscqesze start Android today from the Zero single row La La ~

First of all, from the simplest of beginnings

Requirements:

After the program is run, click the button on the screen to display a word, such as "Hello World!" "

This is the most basic and basic stuff, I don't have much nonsense.

The code is as follows:

//java filesPackage Com.example.helloworld;import android.os.bundle;import android.app.activity;import android.view.Menu; Import Android.view.textureview;import Android.view.view;import Android.view.view.onclicklistener;import Android.widget.TextView; Public classMainactivity<button>extends Activity {Button B;    TextView T; @Overrideprotected voidonCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);                Setcontentview (R.layout.activity_main); b= (Button) This. Findviewbyid (R.id.button1); T= (TextView) This. Findviewbyid (R.id.textview1); (View) b). Setonclicklistener (NewOnclicklistener () { Public voidOnClick (View v) {T.settext ("Hello World");    }        }); }}

Xml:

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"Xmlns:tools="Http://schemas.android.com/tools"Android:layout_width="match_parent"Android:layout_height="match_parent"Android:paddingbottom="@dimen/activity_vertical_margin"Android:paddingleft="@dimen/activity_horizontal_margin"Android:paddingright="@dimen/activity_horizontal_margin"Android:paddingtop="@dimen/activity_vertical_margin"Tools:context=". Mainactivity"> <TextView Android:id="@+id/textview1"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:text=""/> <Button Android:id="@+id/button1"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:layout_below="@+id/textview1"Android:layout_centerhorizontal="true"Android:layout_margintop="134DP"Android:text="let me have some ."/></relativelayout>

source files and drawing: http://pan.baidu.com/s/1nt7fIu1

Android from zero single row first stage button display HelloWorld

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.