标签:android style blog java io for 文件 ar 2014
1.布局文件
<LinearLayout android:id="@+id/viewGroup" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_horizontal" android:orientation="vertical" />
ViewGroup group = (ViewGroup) findViewById(R.id.viewGroup); ImageView[] imageViews = new ImageView[images.length]; for (int i = 0; i < imageViews.length; i++) { ImageView imageView = new ImageView(this); imageView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); imageViews[i] = imageView; imageView.setImageResource(R.drawable.ic_launcher); group.addView(imageView); }这样就可以在不知道图片数量的时候,根据获取到的数量,动态创建ImageView。
标签:android style blog java io for 文件 ar 2014
原文地址:http://blog.csdn.net/lyy1104/article/details/38869245