Android mobile guard -- select SettingItemView to switch the entry status and click the item entry to jump to the page

Source: Internet
Author: User

Android mobile guard -- select SettingItemView to switch the entry status and click the item entry to jump to the page

This article introduces how to customize the control combinations in the previous article.

Whether the checkBox is selected determines whether SettingItemView is enabled.

First, create a method to determine whether checkbox is enabled.

/*** Determine whether to enable the method ** @ return returns the current SettingItemView whether the selected status is true enabled (checkBox returns true) * false disables (checkBox returns true) */public boolean isCheck () {return cb_box.isChecked ();}

Controls the control display text based on the enabled Variables

/*** @ Param isCheck whether it is used as the enabled variable. It is passed by clicking */public void setCheck (boolean isCheck) {// the current entry is selected, the cb_box selection status is also changing with (isCheck) cb_box.setChecked (isCheck (); if (isCheck) {TV _des.setText ("automatic update enabled ");} else {TV _des.setText ("auto update disabled ");}}

Next, add the entry click event:

Package com. wuyudong. mobilesafe. activity; import com. wuyudong. mobilesafe. r; import com. wuyudong. mobilesafe. view. settingItemView; import android. app. activity; import android. OS. bundle; import android. view. view; import android. view. view. onClickListener; public class SettingActivity extends Activity {@ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setConten TView (R. layout. activity_setting); initUpdate ();} private void initUpdate () {final SettingItemView siv_update = (SettingItemView) findViewById (R. id. siv_update); siv_update.setOnClickListener (new OnClickListener () {@ Override public void onClick (View v) {// if it is selected, click, it becomes unselected // if it is not selected before, after clicking it, it becomes selected // get the previously selected status boolean check = siv_update.isCheck (); // reverse the original status, the two operations of appeal are the same as siv_update.setCheck (! Check );}});}}

In this way, when an entry is clicked, the corresponding checkbox status in the custom control also changes accordingly.

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.