//定义一个访问图片的数组
int[] images = new int[]{
R.drawable.java,
R.drawable.ee,
R.drawable.classic,
R.drawable.ajax,
R.drawable.xml,
};

//获取LinearLayout布局容器
LinearLayout main = (LinearLayout)findViewById(R.id.root);

//将ImageView组件添加到LinearLayout布局容器中
main.addView(image);

//初始化时显示第一张图片
image.setImageResource(images[0]);

//在imageView上点击变换照片

public void onClick(View v)
{
if (currentImg >= 4)
{
currentImg = -1;
}
//改变ImageView里显示的图片
image.setImageResource(images[++currentImg]);
}

相关文章:

  • 2021-12-05
  • 2022-12-23
  • 2021-04-29
  • 2021-11-03
  • 2022-01-27
  • 2021-09-23
  • 2022-12-23
  • 2021-12-18
猜你喜欢
  • 2022-02-18
  • 2021-05-27
  • 2021-11-11
  • 2022-02-10
  • 2022-02-19
相关资源
相似解决方案