I wish to use some tabspace in a line where I call setText
if(id==R.id.radioButton1){ title.setText(numbertext.getText()+" Grams");
In this case I would like to tab between numbertekst.getText() and the grams. The output is part of a simple row with values. But as I can't find the tab, the row is a little ugly.
I know I can use multiple textfields or even a table. But as I have a lot of code already I don't want to go that way yet.
I tried the Java way with putting \t, however that seems not to work.
Any help would be appreciated.
If you want to show a strike-through text you can do it programming using PaintFlags. You can set paint flags Paint. STRIKE_THRU_TEXT_FLAG to a TextView and it will add a strike-through to the text. TextView textView = (TextView) findViewById(R.
Set The Text of The TextView You can set the text to be displayed in the TextView either when declaring it in your layout file, or by using its setText() method. The text is set via the android:text attribute. You can either set the text as attribute value directly, or reference a text defined in the strings.
TextView tv1 = (TextView)findViewById(R. id. textView1); tv1. setText("Hello"); setContentView(tv1);
Modify src/MainActivity. java file to add necessary code . Modify the default content of res/layout/activity_main. xml file to include Android UI control.
You should add tabulator to the text, but \t don't work in settext. The solution is add the character \u0009
that represents in unicode char the tabulator, in a string resource.
<string name="tab">\u0009</string> TextView hello = (TextView) findViewById(R.string.helloTextView); hello.setText("e"+getString(R.string.tab)+"e");
just combine more tab to have more space
getString(R.string.tab)+getString(R.string.tab)+getString(R.string.tab)
"\t" works as well, and "\n" is used to start new line
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With