Tạo bộ đếm giờ trong lập trình Android

Tạo bộ đếm giờ trong lập trình Android

Tạo bộ đếm giờ trong lập trình Android

Bước 1: Khai báo một đối tượng CountDownTimer

CountDownTimer count_obj;

Bước 2:

Trong hàm onCreate viết mã sau để tạo mới 1 CountDownTimer, truyền vào 2 tham số.

Tham số 1: Tổng thời gian thực hiện
Tham số 2: Khoảng cách thời gian thực hiện lại hành động

onTick : được gọi sau một khoảng thời gian xác định.
onFinish: được gọi khi kết thúc tổng thời gian.

Code ví dụ:

new CountDownTimer(Tongthoigian, khoangthoigian) {
                
                @Override
                public void onTick(long millisUntilFinished) {
                    // TODO Auto-generated method stub
                    Action   
                }
                
                @Override
                public void onFinish() {
                    // TODO Auto-generated method stub
                    Action
                }
            }.start();
    } 
Bạn thấy bài viết này như thế nào?: 
Average: 10 (1 vote)
Ảnh của Khanh Hoang

Khanh Hoang - Kenn

Kenn is a user experience designer and front end developer who enjoys creating beautiful and usable web and mobile experiences.

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Tại sao cần Linux Virtual Server?

Tại sao cần Linux Virtual Server?

Virtual server là một server ảo được xây dựng trên nhiều server thực, các server thực này dùng chung một public ip, do đó tương tác giữa người dùng với tập hợp server này không khác gì với một server bình thường

Facebook mở rộng quy mô dịch vụ internet miễn phí

Facebook mở rộng quy mô dịch vụ internet miễn phí

Sau khi đã giới thiệu dịch vụ internet miễn phí của mình tại 17 quốc gia đang phát triển, Facebook cho biết sẽ tiếp tục mở rộng dịch vụ này với quy mô lớn hơn bao giờ hết.

Sự vi diệu của Drupal's Extra Fields module một loại Field API

Sự vi diệu của Drupal's Extra Fields module một loại Field API

One of the challenges front-end developers face is adding new components to entity templates that exist outside of what is defined in the Field API; or in other words

Công ty diệt chuột T&C

 

Diet con trung