Android develops a simple page layout

Source: Internet
Author: User

 Packagecom.example.test;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.view.View;ImportAndroid.view.View.OnClickListener;ImportAndroid.view.ViewGroup;ImportAndroid.widget.Button;Importandroid.widget.LinearLayout;ImportAndroid.widget.TextView; Public classMainactivityextendsActivity {//callback This method when the activity is first created@Override Public voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); //Create a linear layout managerLinearLayout layout =NewLinearLayout ( This); //set the activity display layout            Super. Setcontentview (layout);            Layout.setorientation (linearlayout.vertical); //Create a TextView            FinalTextView show =NewTextView ( This); //Create a buttonButton bn =NewButton ( This);            Bn.settext (R.string.ok); Bn.setlayoutparams (Newviewgroup.layoutparams (ViewGroup.LayoutParams.WRAP_CONTENT, VIEWGROUP.LAYOUTPA Rams.            Wrap_content)); //adding TextView to the layout containerLayout.addview (show); //Add a button to the layout containerLayout.addview (BN); //binding an event listener for a buttonBn.setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View v) {Show.settext ("Hello, Android," +Newjava.util.Date ());    }            }); }}

Eclipse is really hard to use.

Android develops a simple page layout

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.