all*_*nth 1 android imageview android-layout kotlin
在我的科特林应用程序我有一些ImageViews(中activity_main.xml): ,,imageView_0 和.imageView_1imageView_2imageView_3
如何在0到3的循环中访问视图?这不起作用:
val imageView: ImageView = findViewById<ImageView>("R.id.imageView_" + index) as ImageView
Run Code Online (Sandbox Code Playgroud)
for(i in 1..3){
val id: int=getResources().getIdentifier("imageview_"+i, "id",
getPackageName())
imageview[i]=findViewById(id) as ImageView
}
Run Code Online (Sandbox Code Playgroud)
如果你在xml,imageview_1,imageview_2,imageview_3
| 归档时间: |
|
| 查看次数: |
1639 次 |
| 最近记录: |