Android Common Controls 1

Source: Internet
Author: User

(1) TextView Description: Display text information in activity(2) EditText Description: Editable text box(3) button description: Buttons

1, bind the Listener for button buttons

The variable name (such as Lio) for which the button's ID has been obtained. Setonclicklistener (new Liolistener ());//After New is the name of the rewrite function for the variable name (such as Lio) that corresponds to the ID of the obtained button that we set

2, Listener function

Class Liolistener implements Onclicklistener

{

public void OnClick (View v)

{Construction Method}

}

(4) Menu Description: Menus control(5) Radiogroup and RadioButton Description: Radio button

Note: Two must be used at the same time, because a radio button in a group can only be selected and set multiple groups when you want to set multiple radio buttons for different content

Listeners for radio button groups:

1. Add Listener for Group "Note the difference between adding listeners with a button"

Group name. Setoncheckdchangedlistener (New Radiogroup.oncheckedchangelistener ()

The public void oncheckedchanged (radiogroup group, int checkedid)//GRUOP indicates that the group's controls were clicked, and the ID of that group was passed in, and the checkid indicates that the group passed in the radio button is clicked, the ID of this radio is passed in.

{

if (Femalebutton.getid () ==checkid)//If the ID of the radio button that represents the female is equal to the passed-in ID, ...

{}

Else if (Maelbutton.getid () ==checkedid)//If the ID of the male is equal to the ID passed in, ...

{}

});

(6) CheckBox Description: Multi-select button

To add a listener to a multi-select button

The name of the multi-select button that obtained the ID. Setoncheckedchangelistener (Newcompoundbutton.oncheckedchangelistener ()

public void OnCheckedChanged (Compoundbutton buttonview, Boolean isChecked)

{if (isChecked)

{}

Else

{}});

(7) Toast Description: Give the user the prompt information

Calling code:

Toast.maketext (Radiotest.this, "Famle", Toast.length_short). Show ();

The first parameter is the activity object that is currently used, the second parameter is to look like a message to the user, such as "Famle", the third parameter sets the length of time the information is displayed

Android Common Controls 1

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.