|
![](/images/resource/spacer.gif) |
|
android ขอคำแนะนำหน่อยคับ เรื่องเสียงในการ random โดย timer อ่ะคับ |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ขอคำแนะนำหน่อยคับ
จะมีวิธีไหนบ้างคับทีพอเวลาเรา กดปุ่ม random แล้วจะไม่เสียงจากรูปแรกกลับมา พูดขึ้นอีกคือ จะให้มันหยุดไปเลยพอกดปุ่ม random ครั้งใหม่
Random rand2=new Random();
ran4=rand2.nextInt(10)+1;//imageVie4 หรือ โจท์ย
if(ran4==1)
{
imageView3.setImageResource(R.drawable.j1);
playsong1 = MediaPlayer.create(this, R.raw.songj1);
playsong1.start();
TimerTask tt = new TimerTask() {
public void run() {
runOnUiThread(new Runnable() {
public void run() {
playsong1.start();
}
});
}
};
Timer tm = new Timer();
tm.schedule(tt, 10000);
new CountDownTimer(15000, // msec to finish
10000) { // msec to tick
public void onTick(long millisUntilFinished) {
playsong1.start();
}
public void onFinish() {
playsong1.stop();
}
};
}
if (ran4 == 2){
imageView3.setImageResource(R.drawable.j2);
playsong2 = MediaPlayer.create(this, R.raw.songj2);
playsong2.start();
TimerTask tt = new TimerTask() {
public void run() {
runOnUiThread(new Runnable() {
public void run() {
playsong2.start();
}
});
}
};
Timer tm = new Timer();
tm.schedule(tt, 10000);
new CountDownTimer(15000, // msec to finish
10000) { // msec to tick
public void onTick(long millisUntilFinished) {
playsong2.start();
}
public void onFinish() {
playsong2.stop();
}
};
}
if (ran4 == 3){
imageView3.setImageResource(R.drawable.j3);
playsong3 = MediaPlayer.create(this, R.raw.songj3);
playsong3.start();
TimerTask tt = new TimerTask() {
public void run() {
runOnUiThread(new Runnable() {
public void run() {
playsong3.start();
}
});
}
};
Timer tm = new Timer();
tm.schedule(tt, 10000);
new CountDownTimer(15000, // msec to finish
10000) { // msec to tick
public void onTick(long millisUntilFinished) {
playsong3.start();
}
public void onFinish() {
playsong3.stop();
}
};
}
Tag : Mobile, Android
![](/images/adv.jpg?v=1001)
|
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2012-09-27 14:41:22 |
By :
mango |
View :
1331 |
Reply :
1 |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 03
|