Android Phone Defender--check Settingitemview entry status Toggle

Source: Internet
Author: User

This article implements the related methods in the custom composite control in the previous article.

checkbox is checked to determine if Settingitemview is turned on.

First, create a method to determine if the checkbox is open

    /**      * Determines whether to open the     method      *@return  Returns whether the current Settingitemview is checked for true on (checkbox returns True)     *         false Off (checkbox returns True)     */public    boolean  Ischeck () {        return  cb_box.ischecked ();    }

Controls display text based on the variable that is turned on

 /**   *    Ischeck is an open variable that is passed through during the click Process  */< /span> public  boolean   Ischeck) { //  The current entry in the process of selection, the Cb_box selected state also follows (Ischeck) changes   cb_box.setchecked (Ischeck ());  if   (Ischeck) {Tv_des.settext ( "        Auto-Update is on ");  else  " Automatic Update        Close "); }    }

Then add the entry click event:

 Packagecom.wuyudong.mobilesafe.activity;ImportCOM.WUYUDONG.MOBILESAFE.R;ImportCom.wuyudong.mobilesafe.view.SettingItemView;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.view.View;ImportAndroid.view.View.OnClickListener; Public classSettingactivityextendsActivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (r.layout.activity_setting);    Initupdate (); }    Private voidinitupdate () {FinalSettingitemview siv_update =(Settingitemview) Findviewbyid (r.id.siv_update); Siv_update.setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View v) {//if it was previously selected, after clicking, it becomes unchecked//if previously unchecked, click to select//gets the previous selected state                BooleanCheck =Siv_update.ischeck (); //reverse the original state, equivalent to the two operations of the appealSiv_update.setcheck (!check);            }        }); }}

This changes the corresponding checkbox state contained in the custom control when the entry is clicked.

Android Phone Defender--check Settingitemview entry status Toggle

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.