Example usage for android.preference PreferenceScreen setOrder

List of usage examples for android.preference PreferenceScreen setOrder

Introduction

In this page you can find the example usage for android.preference PreferenceScreen 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:github.daneren2005.dsub.fragments.SettingsFragment.java

private PreferenceScreen addServer(final int instance) {
    final PreferenceScreen screen = this.getPreferenceManager().createPreferenceScreen(context);
    screen.setKey(Constants.PREFERENCES_KEY_SERVER_KEY + instance);
    screen.setOrder(instance);

    screen.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override/* w ww.j  a va  2s. co m*/
        public boolean onPreferenceClick(Preference preference) {
            SettingsFragment newFragment = new SettingsFragment();

            Bundle args = new Bundle();
            args.putInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, instance);
            newFragment.setArguments(args);

            replaceFragment(newFragment);
            return false;
        }
    });

    return screen;
}

From source file:net.basilwang.StaticAttachmentActivity.java

 private void reloadData(PreferenceCategory logonPreference,
      PreferenceScreen logonAddPreference,
      PreferenceManager preferenceManager) {
   // 2012-11-23 basilwang refresh tabbar title
   refreshActionBarTitle();//from  w  ww  . j a  v  a  2  s.c o m

   logonPreference.removeAll();
   logonPreference.addPreference(logonAddPreference);
   int accountId = PreferenceManager.getDefaultSharedPreferences(this)
         .getInt(LOGON_ACCOUNT_ID, 0);
   AccountService service = new AccountService(this);
   List<Account> list = service.getAccounts();
   if (list.size() == 0) {
      logonAddPreference.setEnabled(true);

   } else {
      logonAddPreference.setEnabled(false);
      for (Account account : list) {
         PreferenceScreen preferenceItem = preferenceManager
               .createPreferenceScreen(this);
         // CheckBoxPreference checkBoxPreference = new
         // CheckBoxPreference(this);
         // make sure each key is unique
         preferenceItem.setKey(LOGON_ACCOUNT_PREFERENCES);
         preferenceItem.setTitle(PreferenceUtils.getPreferUserName(this));
         if (accountId == account.getId())
            preferenceItem.setSummary(R.string.already_checked);
         // preferenceItem.setChecked(false);
         // checkBoxPreference.setDisableDependentsState(disableDependentsState)
         // checkBoxPreference.setSelectable(false);
         preferenceItem.setOrder(0);
         preferenceItem.setOnPreferenceClickListener(this);
         logonPreference.addPreference(preferenceItem);
      }

   }

}