0

i have one EditText and entered some text.

view.editText.setTextColor(Color.RED);
Html.toHtml(editText.getText())

convert it to html text. o/p

text color change

i have getting only paragragh but not the selected color.

2 Answers 2

3

Because,

editText.getText() just returns Editable character sequence not a Html rich string.

Sign up to request clarification or add additional context in comments.

4 Comments

how can we achieve this. any suggestion
you can use editText.getTextColor() and make a custom Html rich text.
actually i am working on the rich text editor so part of the string in edittext having the color. so how can we do this.
For that you have to make custom rich text editor. Extend EditText as base class and implement some method which returns rich text which you want.
0
String sample=editText.getText();
TextView str = new TextView(null);
str.setText(sample);
str.setTextColor(Color.RED);
editText.setText(str.getText().tostring());

or use this

Html.fromHtml("<font color = #ffffff>"
                + getResources().getString(editText.getText().tostring()) + "</font>")

thank you.

2 Comments

can't set textview using setText error at this line editText.setText(str);
try this one.editText.setText(str.getText().tostring());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.