我與編輯文本時支持粗體,斜體和underline.I的性能得到了選擇文本後成功並使其大膽。現在我想在點擊普通按鈕後刪除粗體。如何在Edittext Android中取消選定的文本?
Typeface.NORMAL沒有在這裏工作。任何人都可以提出其他選擇。
Button btnBold = (Button) findViewById(R.id.btnBold);
btnBold.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startSelection = etx.getSelectionStart();
endSelection = etx.getSelectionEnd();
Spannable s = etx.getText();
s.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), startSelection, endSelection, 0);
}
});
Button btnNormal = (Button) findViewById(R.id.btnNormal);
btnNormal .setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
**//What I have to do here.**
}
});
檢查這篇文章,你會發現其餘的。 http://stackoverflow.com/questions/37002177/how-to-bold-or-italic-or-underline-the-selected-text-in-edittext-programatically/42810064#42810064 – Bosco
嘗試在這個崗位HTTP的解決方案://問題/ 37002177/how-to-bold-or-italic-or-underline-the-selected-text-in-edittext-programatically/42810064#42810064 – Bosco