📱Android Studio Part 15 : Countdown Timer (Type 5 Sec left)
#androidstudio #android
การนับถอยหลังแบบ 5 sec left มีดังนี้
1. กำหนดตัวแปร widget
2. คำสั่งเรียกใช้งาน widget
3. เพิ่มคำสั่งนับถอยหลัง
4. ใส่คำสั่งให้ทำงาน
== Code Example ==
// กำหนดตัวแปร widget
TextView t1;
Button b1;
CountDownTimer count;
// คำสั่งเรียกใช้งาน widget
t1 = findViewById(R.id.textView);
b1 = findViewById(R.id.button);
// เพิ่มคำสั่งนับถอยหลัง
count = new CountDownTimer(60000,1000) {
@Override
public void onTick(long mill) {
t1.setText(mill/1000 + " sec left");
}
@Override
public void onFinish() {
t1.setText("time out");
}
};
//ใส่คำสั่งให้ทำงาน
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
count.start();
}
});
* count = new CountDownTimer(5000,1000) ค่าเลขหลังต้องเป็น1000 เท่านั้น *
*I* ค่าเวลา 5000,1000 เท่ากับ 5 วินาที
*II* ค่าเวลา 10000,1000 เท่ากับ 10 วินาที
*III* ค่าเวลา 30000,1000 เท่ากับ 30 วินาที
*IV* ค่าเวลา 60000,1000 เท่ากับ 1 นาที
*V* ค่าเวลา 600000,1000 เท่ากับ 10 นาที
Other Videos By Ikapayabaht
Other Statistics
Countdown Timer Statistics For Ikapayabaht
At this time, Ikapayabaht has 43 views for Countdown Timer spread across 2 videos. Less than an hour worth of Countdown Timer videos were uploaded to his channel, making up less than 0.05% of the total overall content on Ikapayabaht's YouTube channel.