There is some way to make a fraction of the text in a json in Android Studio 2.3 go bold, just like line breaks are done.
I have this json:
{
"array_texto":[
{
"texto"":"Hola mundo",
"texto":"Esto es un hola mundo"
}
]
}
I read the json from the raw folder with this code:
public String LeerFicheroRAW (InputStream fraw){
String linea = null;
try {
BufferedReader brin = new BufferedReader(new InputStreamReader(fraw));
StringBuilder sBuilder = new StringBuilder();
String line = null;
while ((line = brin.readLine()) != null) {
sBuilder.append(line + "\n");
}
linea = sBuilder.toString();
fraw.close();
Log.i("Ficheros", "Fichero RAW leido!");
Log.i("Ficheros", "Texto: " + linea);
} catch (Exception ex) {
Log.e("Ficheros", "Error al leer fichero desde recurso raw");
}
return linea;
}
in the main activity I deserialize the json and I show it in the texview like this:
final InputStream fraw = getResources().openRawResource(R.raw.consti);
String text = aux.LeerFicheroRAW(fraw);
Gson gson = new Gson();
json = gson.fromJson(text, Clase_generica.class);
String texto = "";
for (int i = 0; i < array_texto.size(); i++) {
texto = texto.concat(getArraytexto.get(i).getTexto());
texto = texto.concat("\n\n");
}
textview.setText(texto);
What I want to know is if from the json file you can make the text come in bold by default and it looks like this:
Hello world: This is a hello world
because for example if in the json file I have \ n like this:
{
"array_texto":[
{
"texto"":"Hola mundo",
"texto":"Esto es\n un hola mundo"
}
]
}
then it appears like this when it is shown in the texview:
Hello world
This is
a hello world
Just as the IDE recognizes that "\ n" is a line break, there is something with which you can specify which text to quiro in bold. Any ideas?