android - How to hide dependent Edittextpreferences when a Checkboxpreference is checked? -


Text after "

I rely on an CheckBoxPreference and two EditTextPreferences Checkbox Launch (All are defined in an xml file and all three together PreferenceScreen )

My question is: How to Hide and Reappear the two EditTextPreferences when users unchecks and check respectively Checkbox designation

Currently I just enable / disable Gives them the Android: Dependency to them.

To do this, the solution will be appreciated in Java or xml . :)

I do not know any way to do this through XML, which is always my favorite choice But this Java solution should work.

CheckboxProfrence chkPref = (CheckboxPreference) Search Convention ("myCheckPref"); Edit EditTextPreferenceFix1 = (EditTextPreference) (reference "myEditCheckPref"); Edit priority groupTeckPoint = meet (editProf 1); ChkPref.setOnPreferenceChangeListener (New OnPreferenceChangeListener) {Public Boolean onPreferenceChange (preferred preferred, object value) {if (value) editTextParent.addPreference (editPref1); rest editTextParent.removePreference (editPref1); return true;}});

In order to find a parent's parent group, you also do not have to define these tasks as:

  Personal PreferenceGroup getParent (Priority Priority) {Refund Parent (getPreferenceScreen (), Priority); } Private PreferenceGroup getParent (PreferenceGroup Root, Preferences Preference) {{int i = 0; I & lt; root.getPreferenceCount (); i ++) {Preferences for P = root.getPreference (i); If (P == preferred) return route; If (PreferenceGroup.class.isInstance (p)) {PreferenceGroup parent = getParent (PreferenceGroup) p, Priority); If (parents! = Zero) parents back; }} Return tap; }  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -