MainActivity.java
Код: Выделить всё
ImageView button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
button = findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String string;
int startSelection = descEditText.getSelectionStart();
int endSelection = descEditText.getSelectionEnd();
string = descEditText.getText().toString();
string.substring(startSelection, endSelection);
Spanned s = Html.fromHtml("" + string + "[/b]");
descEditText.setText(s);
}
});
}
Код: Выделить всё
Подробнее здесь: https://stackoverflow.com/questions/752 ... n-edittext
Мобильная версия