请任何人告诉我
如何使用 SharedPreferences 将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);
答案 0 :(得分: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