Android之点击切换图片

package com.example.SlidePictures;

import java.util.Timer;
import java.util.TimerTask; import com.example.flashingpictures.R; import android.media.Image;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.text.format.Time;
import android.view.Menu;
import android.widget.ImageView; public class MainActivity extends Activity {
private Image image;
//定义变化图片
int[] images={
R.drawable.a,
R.drawable.b,
R.drawable.c,
R.drawable.d,
R.drawable.e,
};
//定义传递信息
//0x开头表示16进制
int SING=0x11;
//照片顺序
int num=;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); final ImageView image=(ImageView)findViewById(R.id.imageView);
final Handler handler=new Handler(){ @Override
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
super.handleMessage(msg);
if(msg.what==SING){
image.setImageResource(images[num++]);
if(num>=){
num=;
}
} }
};
new Timer().schedule(new TimerTask() { @Override
public void run() {
// TODO Auto-generated method stub
Message msg=new Message();
msg.what=SING;
handler.sendMessage(msg);
}
}, ,);
} @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
} }

效果执行图:

Android之点击切换图片

上一篇:WAF SSI


下一篇:MySQL开启general_log跟踪sql执行记录