"Android Beginner" 2, view preliminary

Source: Internet
Author: User

1, the basic concept of view

View is the parent class for all control classes. (Text, button, multiple selection, layout, ... ··· )

2. Get the object representing view in activity

Use Findviewbyid (R.ID.PPP);PPP to represent the ID of the control

For example TextView textview= (TextView) Findviewbyid (R.id.textview);

The method returns a view type and must use a control that is transformed downward into a response.

3. Set the properties of the view

Use the object of the previous TextView;

You can modify the Text property of the control, such as: Textview.settext ("Hello World");

4. Set Listener for View

1) Gets the object that represents the control (as mentioned in the 2nd)

2) Define a class that implements a listener interface such as: Define a Onclicklistener interface Buttonlistener

3) Generate listener objects such as: Generate a Onclicklistener object Buttonlistener, the replication of its OnClick method;

4) binds the listener object to the control such as: Button.setonclicklistener (Buttonlistener); After binding, the listener's OnClick method is called whenever the button is pressed.

"===================end========================="

  

  

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.