Я хочу, чтобы установить значение TextView программно, кажется, все в порядке мной, но не знаю, почему установленное значение не отображаетсяAndroid: TextView не показывает значение, установленное программно
Это код:
//set the value of a text view
final TextView textView = (TextView) findViewById(R.id.validityValue);
textView.setText("30 days");
Это то, что у меня в XML-файле
<TextView
android:id="@+id/validityValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textSize="12sp"
android:textColor="#000" />
с выше коде TextView не отображается при запуске приложения.
UPDATE //////// Полный код XML
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:background="@drawable/mobilegrd"
android:padding="10dp"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textSize="25sp"
android:gravity="center_horizontal"
android:textColor="#000"
android:text="Weekly Updates" />
<Spinner
android:id="@+id/spinTunes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6sp"
android:textColor="#000"
android:prompt="@string/tune_prompt" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="#000"
android:text="Singer:" />
<EditText
android:id="@+id/singer"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textColor="#000"/>
<!-- android:inputType="phone" -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="#000"
android:text="Language:" />
<EditText
android:id="@+id/language"
android:inputType="phone"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textColor="#000"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="#000"
android:text="Price:" />
<EditText
android:id="@+id/price"
android:inputType="phone"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textColor="#000"/>
<TextView
android:id="@+id/validityValue"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:textSize="12sp"
android:textColor="#000000" />
<EditText
android:id="@+id/validity"
android:inputType="phone"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textColor="#000"/>
<Button
android:id="@+id/proceed"
android:text="Proceed"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textColor="#000"/>
</LinearLayout>
</ScrollView>
Это выглядит действительно, возможно, есть кое-что еще, что вам не хватает. Пожалуйста, предоставьте нам больше вашего кода. –
В журнале вызывается исключение? –
ваш цвет текста андроид: textColor = "# 000" может быть проблемой, попробуйте с другим цветом – Sree