如果我想要利用imageview 做一個迴圈,例如,接收到5,會顯示5顆星星。但程式碼我不知道是哪邊的想法不對,能否請給我一個方向。謝謝
secondImage = (ImageView) findViewById(R.id.imageView2);
       for ( int i = 0; i < 5; i++ )
        {
     
        secondImage.setBackgroundResource(R.drawable.star);
        }
                        如果只是想要放星星的話,Android本身就有RatingBar可以用喔,可以設定星星數,可以有半顆星,可以換圖片。

<RatingBar
    android:id="@+id/ratingBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="36dp" />
<RatingBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="36dp"
    android:rating="3.5" />
<RatingBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="36dp"
    android:numStars="10"
    android:rating="8" />
Activity
ratingBar.rating = 5.0f