1
I would like to know how to make a certain part of a text that will be displayed in a TEXTVIEW bold:
I would like the text displayed to look like this: Total value => R$ 1100.
Activity:
package genesysgeneration.stackall;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private TextView tvValor;
private Button btnMais100;
int valor;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tvValor=(TextView)findViewById(R.id.tvValor);
btnMais100=(Button)findViewById(R.id.btnMais100);
valor=0;
btnMais100.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
valor+=100;
tvValor.setText(String.valueOf("Valor total => R$ " + valor + "."));
}
});
}
}
I know I could create another Textview, but it doesn’t suit me. I also know I could do it in . xml from Textview, but it’s unfeasible because the text is dynamic (not so much in the example, but in my actual project where I want to use it).
in the case of a text, such a thing becomes unviable
– Boneco Sinforoso
I don’t understand. Can you explain?
– ramaral