I have 2 TextView
s but one of them doesn't show any text. I see in LogCat
that is there but on the app it doesn't show. I'm sure that the problem is in my xml
file but I don't know what exactly. Also I saw a lot of posts like this here and I've tried different thing from them but non is helped me. Here is the layout
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="320dp"
android:layout_height="wrap_content"
android:minHeight="50dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="300dp"
android:layout_height="0dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_weight="10.18"
android:background="@drawable/buttons"
android:orientation="vertical" >
<TextView
android:id="@+id/name"
android:layout_width="280dp"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:text="" />
<TextView
android:id="@+id/text"
android:layout_width="280dp"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:layout_marginTop="10dp"
android:text="" />
</LinearLayout>
<LinearLayout
android:layout_width="300dp"
android:layout_height="fill_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<Button
android:id="@+id/pressMe"
android:layout_width="300dp"
android:layout_height="40dp"
android:layout_marginTop="5dp"
android:background="@drawable/bg_button"
android:gravity="center"
android:padding="4dp"
android:text="@string/PressMe" />
<Button
android:id="@+id/dontPress"
android:layout_width="300dp"
android:layout_height="40dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="@drawable/bg_button"
android:gravity="center"
android:padding="4dp"
android:text="@string/DontPressMe" />
</LinearLayout>
</LinearLayout>
</ScrollView>
The problematic TextView
is "@+id/name"
Also I get them from another activity via putExtra
and getExtra
intent.putExtra("text", stocks[position].text);
intent.putExtra("name", stocks[position].name);
and
Bundle b = getIntent().getExtras();
if (b != null) {
name = b.getString("name");
textView.setText(name+"");
text = b.getString("text");
textView.setText(text+"");
So the text
is there but name
is missing. On the first Activity both are there.
textView = (TextView) findViewById(R.id.name);
textView = (TextView) findViewById(R.id.text);