I have a text view that is by itself as part of a linear layout. The XML is:
<TextView
android:id="@+id/label_text"
android:layout_width="fill_parent"
android:layout_height="77dp"
android:layout_marginTop="3dp"/>
In the main program I first set the text view to a value:
private TextView character_speaking;
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
character_speaking = (TextView) findViewById(R.id.label_text);
character_speaking.setText("a text string that was large enough for two lines");
}
This works well.
Then I do another setText in response to a button push:
public void handleNextButtonClick(View view) {
character_speaking.setText("first one line message");
}
And this worked as well
But then I did another setText in response to another button push:
public void handlePrevButtonClick(View view) {
character_speaking.setText("second one line message");
}
And disaster strikes. The second one line message writes over the first one line message without clearing it.
Is there anyway to clear the first one line message before writing the second one line message?
I have already tried to get around this problem by using an EditText instead of a TextEdit but this was not acceptable because it allowed the user to write in the field.
I've encountered this similar issue. What made it work is funny -> I just put a black background color to my layout (LinearLayout) and it is working fine now.
It seems the background is not cleared, if it doesn't know what color to clear it with.
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