Example usage for android.preference EditTextPreference setOrder

List of usage examples for android.preference EditTextPreference setOrder

Introduction

In this page you can find the example usage for android.preference EditTextPreference setOrder.

Prototype

public void setOrder(int order) 

Source Link

Document

Sets the order of this Preference with respect to other Preference objects on the same level.

Usage

From source file:im.vector.fragments.VectorSettingsPreferencesFragment.java

private void addButtons() {
    // display the "add email" entry
    EditTextPreference addEmailPreference = new EditTextPreference(getActivity());
    addEmailPreference.setTitle(R.string.settings_add_email_address);
    addEmailPreference.setDialogTitle(R.string.settings_add_email_address);
    addEmailPreference.setKey(ADD_EMAIL_PREFERENCE_KEY);
    addEmailPreference.setIcon(CommonActivityUtils.tintDrawable(getActivity(),
            ContextCompat.getDrawable(getActivity(), R.drawable.ic_add_black),
            R.attr.settings_icon_tint_color));
    addEmailPreference.setOrder(100);
    addEmailPreference.getEditText()//from w ww.  j  a  v a  2 s  . c o m
            .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);

    addEmailPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            final String email = (null == newValue) ? null : ((String) newValue).trim();

            getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    addEmail(email);
                }
            });

            return false;
        }
    });

    mUserSettingsCategory.addPreference(addEmailPreference);

    // display the "add phone number" entry
    Preference addPhoneNumberPreference = new Preference(getActivity());
    addPhoneNumberPreference.setKey(ADD_PHONE_NUMBER_PREFERENCE_KEY);
    addPhoneNumberPreference.setIcon(CommonActivityUtils.tintDrawable(getActivity(),
            ContextCompat.getDrawable(getActivity(), R.drawable.ic_add_black),
            R.attr.settings_icon_tint_color));
    addPhoneNumberPreference.setTitle(R.string.settings_add_phone_number);
    addPhoneNumberPreference.setOrder(200);

    addPhoneNumberPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent intent = PhoneNumberAdditionActivity.getIntent(getActivity(),
                    mSession.getCredentials().userId);
            startActivityForResult(intent, REQUEST_NEW_PHONE_NUMBER);
            return true;
        }
    });

    mUserSettingsCategory.addPreference(addPhoneNumberPreference);
}