Format part of Textview in an event [duplicate]

0

Talk to people, I apologize if the question is repeated, but I looked and I could not solve my problem.

I need the following: The user enters a String and the app returns another String just like it, but if there is any string repeated in the word it is bold and in another color.

Ex: The user type "Canjica" the app returns "Canjica" but with the first "Ca" and the last "ca" in bold and of another color, because they are the same sequences.

I have already done the code to recognize the repeated sequences, I already have the position of the first and last sequence in the string and I already have the size of them.

I just do not know how to change Textview into parts, leaving only a few different parts.

Can anyone help me? Thanks Galeta

    
asked by anonymous 22.03.2017 / 12:29

1 answer

1

In order to do this, you do not need to edit TextView but rather insert code into your text, using the following example:

String sourceString = "<b>" + texto+ "</b> " + texto; 
mytextview.setText(Html.fromHtml(sourceString));

result

text text

or Unicode characters

    
22.03.2017 / 12:38