Java Code Examples for android.preference.Preference#setLayoutResource()

The following examples show how to use android.preference.Preference#setLayoutResource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MaterialEditTextPreference.java    From 920-text-editor-v2 with Apache License 2.0 6 votes vote down vote up
public static void setLayoutResource(@NonNull Context context, @NonNull Preference preference, @Nullable AttributeSet attrs) {
    boolean foundLayout = false;
    if (attrs != null) {
        for (int i = 0; i < attrs.getAttributeCount(); i++) {
            final String namespace = ((XmlResourceParser) attrs).getAttributeNamespace(0);
            if (namespace.equals("http://schemas.android.com/apk/res/android") &&
                    attrs.getAttributeName(i).equals("layout")) {
                foundLayout = true;
                break;
            }
        }
    }

    boolean useStockLayout = false;
    if (attrs != null) {
        TypedArray a = context.getTheme().obtainStyledAttributes(attrs, com.afollestad.materialdialogs.commons.R.styleable.Preference, 0, 0);
        try {
            useStockLayout = a.getBoolean(com.afollestad.materialdialogs.commons.R.styleable.Preference_useStockLayout, false);
        } finally {
            a.recycle();
        }
    }

    if (!foundLayout && !useStockLayout)
        preference.setLayoutResource(com.afollestad.materialdialogs.commons.R.layout.md_preference_custom);
}
 
Example 2
Source File: SettingsFragment.java    From phphub-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    if (Utils.hasLoggedIn(getActivity(), accountManager) && (findPreference(LOGOUT_KEY) == null)) {
        Preference logoutPreference = new Preference(getActivity());
        logoutPreference.setKey(LOGOUT_KEY);
        logoutPreference.setLayoutResource(R.layout.common_logout);
        logoutPreference.setOnPreferenceClickListener(this);
        getPreferenceScreen().addPreference(logoutPreference);
    }
}
 
Example 3
Source File: SettingsFragment.java    From Linphone4Android with GNU General Public License v3.0 4 votes vote down vote up
private void hidePreference(Preference preference) {
	preference.setLayoutResource(R.layout.hidden);
}
 
Example 4
Source File: BaseImplementation.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
private void markFieldInvalid(Preference field) {
	field.setLayoutResource(R.layout.invalid_preference_row);
}
 
Example 5
Source File: BaseImplementation.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
private void markFieldValid(Preference field) {
	field.setLayoutResource(R.layout.valid_preference_row);
}