Android Multi-Status button ToggleButton

Source: Internet
Author: User

ToggleButton selected, unchecked, and you need to set different display text for different states. Property: Checked= "true" textoff= "" texton= ""Private ToggleButton TB ;Private ImageView IV ;TB= (ToggleButton) Findviewbyid (r.id.ToggleButton1);      IV= (ImageView) Findviewbyid (r.id. ImageView1);      //Set listener for ToggleButton       TB. Setoncheckedchangelistener ( New Oncheckedchangelistener () {      @Override      Public void oncheckedchanged (Compoundbutton Buttonview, Boolean isChecked) {           /** When the TB is clicked, the current method is executed* Buttonview represents the skill of the clicked Control (object)* IsChecked represents the status of the clicked Control (on/off)            */             IV. Setimageresource (isChecked? R.drawable. on: r.drawable.Ic_launcher);         }      }); <ToggleButton        Android:id="@+id/togglebutton1"        Android:layout_width="Match_parent"        Android:layout_height="Wrap_content"        Android:texton="@string/texton"        Android:textoff="@string/textoff"        Android:hint="@string/togglebutton" />     <ImageView        Android:id="@+id/imageview1"        Android:layout_width="Match_parent"        Android:layout_height="200DP"        android:src="@drawable/ic_launcher" />

Android Multi-Status button ToggleButton

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.