Java 如何使FOR循环更改已通过循环准备就绪的文本的颜色?
在搜索了几个小时后,我仍然不知道如何使它工作 我有一些数字: 和一个lop,这是增加数字大小,你可以看到在图片上 我想做另一个lop,就是把过去的数字变成绿色,所以当这个数字结束,循环转到下一个,过去的数字变成绿色,就像一个检查算法 MainActivity.java(用于循环)Java 如何使FOR循环更改已通过循环准备就绪的文本的颜色?,java,loops,for-loop,Java,Loops,For Loop,在搜索了几个小时后,我仍然不知道如何使它工作 我有一些数字: 和一个lop,这是增加数字大小,你可以看到在图片上 我想做另一个lop,就是把过去的数字变成绿色,所以当这个数字结束,循环转到下一个,过去的数字变成绿色,就像一个检查算法 MainActivity.java(用于循环) int[]计数; int电流计数; 文本视图countText; 私有void createCountsView(){ countsList.removeallview(); 对于(int i=0;i int[] co
int[]计数;
int电流计数;
文本视图countText;
私有void createCountsView(){
countsList.removeallview();
对于(int i=0;i
int[] counts;
int currentCount;
TextView countText;
private void createCountsView() {
countsList.removeAllViews();
for(int i = 0; i<counts.length; i++){
int res = currentCount == i ? R.layout.workout_count_current : R.layout.workout_count;
View row = inflater.inflate(res,null);
TextView count = (TextView)row.findViewById(R.id.w_count_value);
count.setText(String.valueOf(counts[i]));
countsList.addView(row);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/w_count_value"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="5sp"
android:layout_marginEnd="296dp"
android:textColor="#ff0000"
android:textSize="25dp" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/w_count_value"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="5sp"
android:layout_marginEnd="296dp"
android:textColor="#ffffff"
android:textSize="35dp"
android:textStyle="bold" />
</LinearLayout>