I Textviews wollen Texte innerhalb for-Schleife in Android Studio, so etwas ändern:Textviews Textänderung in einer for-Schleife
für i = 0 ------------> textView0 set Text "Default"
für i = 1 ------------> textView1 Text "Default" gesetzt
für i = 2 ---------- -> textView2 set text "Default"
Ist das möglich? Ich weiß nicht, wie man die TextView ID innerhalb der Schleife nach "i" -Wert ändern kann, kann mir jemand helfen?
Hier ist meine XML:
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="--------------"
android:id="@+id/textView0"
android:layout_marginLeft="16dp"
android:layout_gravity="center_horizontal"
android:textSize="13dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="--------------"
android:id="@+id/textView1"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="16dp"
android:textSize="13dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="--------------"
android:id="@+id/textView2"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="16dp"
android:textSize="13dp" />
Sie eine Reihe von Textview –
ja Objekte einrichten können, ist es ziemlich möglich ist. Sie können in die untergeordneten Ansichten des übergeordneten TextView-Objekts eine Schleife einfügen. Bitte zeigen Sie Ihre XML, so dass wir sehen könnten, ob das hier der Fall ist. –
Kasse meine Lösung @Tymek T. –