android - Unable to set text in a Text View -
i have strange problem using android studio. can't set text of textview (tax), reference isn't 'null pointer', , haven't error or exception, don't see text.
my main class:
@override public void oncreate(bundle savedinstancestate) { setcontentview(r.layout.main); super.oncreate(savedinstancestate); getwindow().setfeatureint(window.feature_custom_title, r.layout.custom_title); tax = (textview) findviewbyid(r.id.ax); tax.settext("prova"); // set custom title mtitle = (textview) findviewbyid(r.id.title_left_text); // mtitle.settext(r.string.app_name); mtitle = (textview) findviewbyid(r.id.title_right_text); // local bluetooth adapter mbluetoothadapter = bluetoothadapter.getdefaultadapter(); // if adapter null, bluetooth not supported if (mbluetoothadapter == null) { toast.maketext(this, "bluetooth not available", toast.length_long).show(); finish(); return; } }
xml main :
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:weightsum="1"> <textview android:id="@+id/ax" android:layout_width="198dp" android:layout_height="38dp" android:textsize="20dp" android:visibility="visible" android:background="#ffffffff" android:textcolor="#fff" /> </linearlayout>
thank's you!
update:
thank's you! can set text 1 time(the first time)! in class, try set text reference (using tax reference static , public), them doesn't change, remains first, , android studio print on console error:
only original thread created view hierarchy can touch views
remotebluetooth.tax.settext(string.valueof(ax));
you can fix error using id starting lowercase letter. android seems have problem id's starting uppercase letter.
Comments
Post a Comment