خرید بک لینک

Vote count: 0

I'd like to know how to fill EditText field with the values of SharedPreferences. My code is as follows:

 protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(this);
        sharedPreferences = getSharedPreferences(getString(R.string.preference_file_key),MODE_PRIVATE);
        textViewCheck();
    }

    public void textViewCheck()
    {
        EditText sil_key = (EditText)findViewById(R.id.silent_key);
        String silent_mode_key = sil_key.toString();
        EditText gen_key = (EditText)findViewById(R.id.general_key);
        String general_mode_key = gen_key.toString();
        EditText vib_key = (EditText)findViewById(R.id.vibrate_key);
        String vibrate_mode_key = vib_key.toString();
        SharedPreferences.Editor editor = sharedPreferences.edit();
        if((sharedPreferences.contains("silent")) && (sharedPreferences.contains("general")) && (sharedPreferences.contains("vibrate")))
        {
            sil_key.setText(sharedPreferences.getString("silent","silent"));
            gen_key.setText(sharedPreferences.getString("general","general"));
            vib_key.setText(sharedPreferences.getString("vibrate","vibrate"));
        }
        editor.putString("silent",silent_mode_key);
        editor.putString("general",general_mode_key);
        editor.putString("vibrate",vibrate_mode_key);
        editor.apply();
    }

I keep getting android.support.design in the EditText fields. I would like to know why I keep getting this and how to overcome this.

asked 6 mins ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 12 خرداد 1395 ساعت: 0:12

صفحه بندی