Reputation: 153
I can't seem to get things to display programatically using text views? I have a main.xml:
<?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"
>
<TextView android:id="@+id/username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Name"
/>
<Button android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a Button"
/>
</LinearLayout>
Then in my code, I use:
//Update the GUI
setContentView(R.layout.main);
TextView guiStr;
guiStr = (TextView)findViewById(R.id.username);
guiStr.setText(username);
But the username does not display on the screen. I get just the default text in the XML. What am I doing wrong?
Upvotes: 0
Views: 640
Reputation: 43412
Probably you have another TextView with the same id. Try assigning your TextView another id - username1 for example
Upvotes: 1