Как сохранить стиль EditText (полужирный, курсив, цвет и т. Д.), Используя Sharedpreferences - PullRequest
0 голосов
/ 22 октября 2018

Пожалуйста, кто-нибудь подскажет, как сохранить text selected в EditText (жирным, курсивом, цветом и т. Д.), Используя SharedPreferences .

Вот мой код:

int selectionStart = editTxt.getSelectionStart();    
int selectionEnd = editTxt.getSelectionEnd();                                
SpannableStringBuilder  stringBuilder = (SpannableStringBuilder) editTxt.getText();   
TextAppearanceSpan styleRed_Bold = new TextAppearanceSpan(getBaseContext(), R.style.CustomStyle);                                             stringBuilder.setSpan(styleRed_Bold , selectionStart , selectionEnd , 0);

1 Ответ

0 голосов
/ 22 октября 2018
SharedPreferences pref = getApplicationContext().getSharedPreferences("MyPref", 0); 

Editor editor = pref.edit();

editor.putString("edittext", "text of your edit text"); 

editor.putString("style", "bold"); 

editor.apply
...