Eclipse安卓图片之间跳转在帧布局下实现一个页面的图片之间的跳转
答案:1 悬赏:0
解决时间 2021-11-29 03:36
- 提问者网友:浪子生来ˇ性放荡²↘
- 2021-11-28 14:32
Eclipse安卓图片之间跳转在帧布局下实现一个页面的图片之间的跳转
最佳答案
- 二级知识专家网友:丢不掉的轻狂
- 2021-11-28 15:33
public class SplideActivity extends Activity {
ImageView image;
Button button;
LinearLayout layout;
boolean tag;
int[] resource = new int[] { R.drawable.ic_launcher1,
R.drawable.ic_launcher2, R.drawable.ic_launcher3 };
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
layout = new LinearLayout(this);
button = new Button(this);
image = new ImageView(this);
button.setText("开始播放");
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(button, new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
layout.addView(image, new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
setContentView(layout);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (tag) {
tag = false;
button.setText("开始播放");
} else {
tag = true;
button.setText("停止播放");
}
}
});
thread.start();
}
Handler handler = new Handler() {
int cpic = 0;
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
image.setBackgroundResource(resource[cpic++ % resource.length]);
}
};
Thread thread = new Thread() {
@Override
public void run() {
while (true) {
if (tag) {
Message msg = handler.obtainMessage();
msg.sendToTarget();
}
try {
sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
}
ImageView image;
Button button;
LinearLayout layout;
boolean tag;
int[] resource = new int[] { R.drawable.ic_launcher1,
R.drawable.ic_launcher2, R.drawable.ic_launcher3 };
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
layout = new LinearLayout(this);
button = new Button(this);
image = new ImageView(this);
button.setText("开始播放");
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(button, new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
layout.addView(image, new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
setContentView(layout);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (tag) {
tag = false;
button.setText("开始播放");
} else {
tag = true;
button.setText("停止播放");
}
}
});
thread.start();
}
Handler handler = new Handler() {
int cpic = 0;
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
image.setBackgroundResource(resource[cpic++ % resource.length]);
}
};
Thread thread = new Thread() {
@Override
public void run() {
while (true) {
if (tag) {
Message msg = handler.obtainMessage();
msg.sendToTarget();
}
try {
sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯