[Android] Development Day Nineth

Source: Internet
Author: User

The following code uses code entirely to control the UI interface and is not recommended.
 PackageCom.oazzz.test2;Importandroid.graphics.LinearGradient;Importandroid.support.v7.app.AppCompatActivity;ImportAndroid.os.Bundle;ImportAndroid.view.View;ImportAndroid.view.ViewGroup;ImportAndroid.widget.Button;Importandroid.widget.LinearLayout;ImportAndroid.widget.TextView; Public classMainactivityextendsappcompatactivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); //Setcontentview (R.layout.activity_main); //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 ("OK"); Bn.setlayoutparams (Newviewgroup.layoutparams (ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRA        P_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 (NewView.onclicklistener () {@Override Public voidOnClick (view view) {Show.settext ("Triggered a click event! "+Newjava.util.Date ());    }        }); }}

[Android] Development Day Nineth

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.