我有一个图像数组。 我需要在一行中显示3个图像,然后在另一行显示下一个图像。 如何使用嵌套for循环执行此操作。任何人都可以帮助我吗? 谢谢。在android中嵌套循环
0
A
回答
0
基本嵌套的循环结构是这样的:
int imageIndex = 0;
for (int row = 0; row < rowCount; row++) {
for (int column = 0; column < columnCount; column++ {
// Draw your image here at x position of (column * image width)
// and y position of (row * image height). Add a bit to each if you
// want some spacing between your images.
// For example:
drawMyImage(images[imageIndex++], column * imageWidth, row * imageHeight);
}
}
0
您需要两个循环。 外循环用于行。行中的每个元素都对应一列,所以内部循环是针对列的。
1
其简单,使用GridView 3列。
<GridView
android:layout_height="wrap_content"
android:id="@+id/gridView1"
android:layout_width="match_parent"
android:numColumns="3"
android:horizontalSpacing="10dp"
android:verticalSpacing="10dp">
相关问题
- 1. 在while循环中嵌套循环 - Java
- 2. for循环嵌套在while循环中
- 3. End =''在嵌套循环中
- 4. 循环嵌套
- 5. 嵌套循环
- 6. C++嵌套循环
- 7. 嵌套循环Javascript
- 8. java嵌套循环
- 9. 与嵌套循环
- 10. 嵌套for循环
- 11. Java:嵌套循环
- 12. SQL嵌套循环
- 13. 嵌套'for'循环
- 14. C#嵌套循环
- 15. Coontaining嵌套循环
- 16. Ant嵌套循环
- 17. Genshi:嵌套循环
- 18. VBA:嵌套/循环
- 19. C++嵌套循环
- 20. 嵌套setInterval循环
- 21. 嵌套foreach循环
- 22. r嵌套循环
- 23. 嵌套循环Smalltalk
- 24. C# - 嵌套循环
- 25. Python:嵌套循环
- 26. PHP嵌套循环
- 27. 嵌套for循环
- 28. 嵌套循环Imacros
- 29. C++嵌套循环
- 30. Xsl嵌套循环