|
![](/images/resource/spacer.gif) |
|
Android ถ้าต้องการจับเวลาเมื่อกดปุ่มหยุดเวลาแล้วให้รับค่าเวลามาเปรียบเทียบกับเงื่อนไขคะแนนที่ได้ |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ใช้ Widgets ตัวไหนครับ ? ใช่ Chronometer หรือเปล่าครับ
|
![](/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 :
2014-10-01 09:38:43 |
By :
mr.win |
|
![](/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/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
สวัสดีครับ
ตอนนี้ผมสร้างปุ่ม btn1 มาและสั่งให้มันดีเลเปลี่ยนเสียงที่เล่น ทุกๆ 5 วิ ในที่นี้มี mMedia1 ถึง mMedia3
ถ้าจะสร้างปุ่มอีกอัน เพื่อเป็นปุ่มตอบรับเช่น สมมุติกดหยุดเล่นแล้ว mMedia2.stop(); ก็ให้ 20 คะแนน mMedia1.stop();ให้ 10 คะแนน มีแนวทางการเขียนอย่างไรดีครับ ไปต่อไม่ถูกเลยครับ ![](/images/bbcode/roll.gif?v=1001) ![](/images/bbcode/roll.gif?v=1001) ![](/images/bbcode/roll.gif?v=1001)
Code (Android-Java)
package com.hearingtest.hearing;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.os.Handler;
import android.widget.TextView;
public class MyActivity extends Activity {
MediaPlayer mMedia;
MediaPlayer mMedia2;
MediaPlayer mMedia3;
private Handler mHandler = new Handler();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_my);
if(mMedia != null){
mMedia.reset();
mMedia.release();
}
mMedia = MediaPlayer.create(this, R.raw.m);
mMedia2 = MediaPlayer.create(this, R.raw.m2);
mMedia3 = MediaPlayer.create(this, R.raw.m);
final Button btn1 = (Button) findViewById(R.id.btnstarttest); // Start
final Button btn2 = (Button) findViewById(R.id.button2); //respond
// Start
btn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mMedia.start();
btn1.setEnabled(false);
mHandler.postDelayed(new Runnable() {
public void run() {
mMedia.stop();
mMedia2.start();
mHandler.postDelayed(new Runnable() {
public void run() {
mMedia2.stop();
mMedia3.start();
}
}, 5000);
}
}, 5000);
}
});
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
if(mMedia != null){
mMedia.release();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.my, menu);
return true;
}
}
|
![](/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 :
2014-10-06 02:13:52 |
By :
giftcardbkk |
|
![](/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 01
|