The attribute
android:id="@+id/textview"of the
TextView
in the
main.xml
int
named
R.id.textview
R.java
@+
in the id.
The method
findViewById
in the
Activity
in
ReferenceActivity.java
R.id.textview
View
.
The reference must be cast into a reference to a
TextView
before it can be stored in a
TextView
variable.
findViewById
cannot be called before
setContentView
.
Remember to add the
android:id
TextView
in
main.xml
,import
for class
Toast
in
ReferenceActivity.java
.
TextView
.
Toast.makeText(this, "textView.getTextSize() == " + textView.getTextSize(), Toast.LENGTH_LONG).show();
textView.getTextSize() == 21.0Colors are conventionally printed in hexadecimal. A shade of gray has equal amounts of red, green, and blue. The alpha comes first.
Toast.makeText(this, "textView.getCurrentTextColor() == " + String.format("%08X", textView.getCurrentTextColor()), Toast.LENGTH_LONG).show();
textView.getCurrentTextColor() == FFBEBEBE
TextView
.
textView.setText("Your message here.");