public class MainActivity extends Activity { //定
publicclassMainActivityextendsActivity{//定义一个访问图片的数组privateint[]images={R.drawable.pi...
public class MainActivity extends Activity {
//定义一个访问图片的数组
private int[] images={R.drawable.pic_01,R.drawable.pic_02,R.drawable.pic_03,R.drawable.pic_04};
//定义初始图片
private int currentImg=2;
//定义图片的初始透明度值
private int alpha=255;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button bt_plus=(Button)findViewById(R.id.bt_01);
Button bt_minus=(Button)findViewById(R.id.bt_02);
Button bt_next=(Button)findViewById(R.id.bt_03);
final ImageView iv_big=(ImageView)findViewById(R.id.iv_01);
ImageView iv_small=(ImageView)findViewById(R.id.iv_02);
bt_next.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
iv_big.setImageResource(images[++currentImg % images.length]);
}
});
最后一句看不懂啊!
} 展开
//定义一个访问图片的数组
private int[] images={R.drawable.pic_01,R.drawable.pic_02,R.drawable.pic_03,R.drawable.pic_04};
//定义初始图片
private int currentImg=2;
//定义图片的初始透明度值
private int alpha=255;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button bt_plus=(Button)findViewById(R.id.bt_01);
Button bt_minus=(Button)findViewById(R.id.bt_02);
Button bt_next=(Button)findViewById(R.id.bt_03);
final ImageView iv_big=(ImageView)findViewById(R.id.iv_01);
ImageView iv_small=(ImageView)findViewById(R.id.iv_02);
bt_next.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
iv_big.setImageResource(images[++currentImg % images.length]);
}
});
最后一句看不懂啊!
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询