我想改变textViews'文本内部的循环Android Studio中,这样的事情:TextViews文本更改为循环
对于i = 0 ------------> textView0设置文本 “默认”
对于i = 1 ------------> textView1设置文本 “默认”
对于i = 2 ---------- - > textView2设置文本“默认”
是否有可能这样做?我不知道如何根据“我”值更改循环内的textView id,有人可以帮助我吗?
这里是我的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" />
可以设置TextView的对象数组 –
是的,这是相当可能的。您可以循环到TextView父级的子视图中。请显示您的XML,以便我们可以看到这是否是这种情况。 –
结帐我的解决方案@Tymek T. –