如何使用共享首选项存储编辑文本样式(粗体、斜体、颜色等)



请任何人告诉我 如何使用共享首选项text selected保存在EditText中(粗体、斜体、颜色等(。

这是我的代码:

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);
SharedPreferences pref = getApplicationContext().getSharedPreferences("MyPref", 0); 
Editor editor = pref.edit();
editor.putString("edittext", "text of your edit text"); 
editor.putString("style", "bold"); 
editor.apply

相关内容

  • 没有找到相关文章

最新更新