亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

annuaire recherche
android Manifest Manifest.permission Manifest.permission_group android.accessibilityservice AccessibilityService android.accounts Account android.app NotificationManager android.bluetooth BluetoothAdapter BluetoothClass BluetoothClass.Device BluetoothClass.Device.Major BluetoothClass.Service BluetoothDevice BluetoothServerSocket BluetoothSocket android.content SharedPreferences android.database.sqlite SQLiteCursorDriver SQLiteOpenHelper android.graphics Bitmap android.location LocationListener Geocoder GpsStatus GpsStatus.Listener GpsStatus.NmeaListener GpsSatellite android.media AudioFormat AsyncPlayer AudioRecord AudioRecord.OnRecordPositionUpdateListener ThumbnailUtils AudioManager android.net TrafficStats MailTo LocalSocket android.os AsyncTask AsyncTask.Status CountDownTimer Message MessageQueue HandlerThread android.text Html android.util JsonWriter android.view ContextMenu ContextMenu.ContextMenuInfo Display ViewManager View ViewStub ViewTreeObserver ViewParent WindowManager GestureDetector Gravity MenuInflater ScaleGestureDetector SoundEffectConstants android.view.inputmethod InputConnection InputMethod InputMethodSession BaseInputConnection InputMethodManager android.widget AbsListView AbsListView.LayoutParams AbsListView.OnScrollListener AbsListView.RecyclerListener AbsoluteLayout AbsoluteLayout.LayoutParams AbsSeekBar AbsSpinner AdapterView AdapterView.AdapterContextMenuInfo AdapterView.OnItemLongClickListener AdapterView.OnItemSelectedListener AdapterView.OnItemClickListener AnalogClock BaseAdapter BaseExpandableListAdapter Button CheckBox CheckedTextView Checkable Chronometer Chronometer.OnChronometerTickListener CompoundButton CompoundButton.OnCheckedChangeListener CursorAdapter CursorTreeAdapter DatePicker DatePicker.OnDateChangedListener DialerFilter DigitalClock EditText Filter Filter.FilterListener Filter.FilterResults ExpandableListAdapter ExpandableListView.OnChildClickListener ExpandableListView.OnGroupClickListener ExpandableListView.OnGroupCollapseListener ExpandableListView.OnGroupExpandListener Filterable Gallery Gallery.LayoutParams GridView GridLayout GridLayout.Alignment RadioGroup ImageView ImageView.ScaleType HorizontalScrollView ImageButton ImageSwitcher FilterQueryProvider ListAdapter ListView MediaController MultiAutoCompleteTextView MultiAutoCompleteTextView.CommaTokenizer MultiAutoCompleteTextView.Tokenizer QuickContactBadge RadioButton RatingBar RatingBar.OnRatingBarChangeListener RelativeLayout RemoteViews ResourceCursorAdapter ResourceCursorTreeAdapter Scroller ScrollView SearchView SearchView.OnCloseListener SearchView.OnQueryTextListener SearchView.OnSuggestionListener SeekBar SeekBar.OnSeekBarChangeListener SimpleAdapter SimpleAdapter.ViewBinder SimpleCursorAdapter SimpleCursorAdapter.CursorToStringConverter SimpleCursorAdapter.ViewBinder SimpleCursorTreeAdapter SimpleCursorTreeAdapter.ViewBinder SimpleExpandableListAdapter SlidingDrawer SlidingDrawer.OnDrawerCloseListener SlidingDrawer.OnDrawerOpenListener SlidingDrawer.OnDrawerScrollListener Spinner SpinnerAdapter WrapperListAdapter TabHost TabHost.TabSpec TextView TimePicker TimePicker.OnTimeChangedListener Toast TableLayout TableLayout.LayoutParams TableRow TableRow.LayoutParams TabWidget TextSwitcher ToggleButton TwoLineListItem VideoView ViewAnimator ViewFlipper ViewSwitcher ViewSwitcher.ViewFactory ZoomButtonsController ZoomButtonsController.OnZoomListener ZoomButton ZoomControls dalvik.system DexFile
personnages


CountDownTimer

版本:Android 4.0 r1

?

結(jié)構(gòu)

繼承關(guān)系

public abstract class CountDownTimer extends Object

????????

java.lang.Object

android.os.CountDownTimer

?

類概述

定時(shí)執(zhí)行在一段時(shí)候后停止的倒計(jì)時(shí),在倒計(jì)時(shí)執(zhí)行過程中會(huì)在固定間隔時(shí)間得到通知(譯者:觸發(fā)onTick方法),下面的例子顯示在一個(gè)文本框中顯示一個(gè)30s倒計(jì)時(shí):

?new CountdownTimer(30000, 1000) {

? ? ?public void onTick(long millisUntilFinished) {

? ? ? ? ?mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);

? ? ?}

? ? ?public void onFinish() {

? ? ? ? ?mTextField.setText("done!");

? ? ?}

? }.start();?

onTick的調(diào)用是同步的,保證這次調(diào)用不會(huì)在之前調(diào)用完成前發(fā)生。這里的同步機(jī)制主要是用來:onTick的實(shí)現(xiàn)需要很多時(shí)間執(zhí)行比倒計(jì)時(shí)間隔更重要的事情。

?

構(gòu)造函數(shù)

???????? public CountDownTimer (long millisInFuture, long countDownInterval)

參數(shù)

?????????????????? millisInFuture? 從開始調(diào)用start()到倒計(jì)時(shí)完成并onFinish()方法被調(diào)用的毫秒數(shù)。(譯者注:倒計(jì)時(shí)時(shí)間,單位毫秒)

?????????????????? countDownInterval ? 接收onTick(long)回調(diào)的間隔時(shí)間。(譯者注:?jiǎn)挝缓撩耄?/span>

?

公共方法

public final void cancel ()

???????? 取消倒計(jì)時(shí)(譯者:取消后,再次啟動(dòng)會(huì)重新開始倒計(jì)時(shí))????????

??????????????????

public abstract void onFinish ()

???????? 倒計(jì)時(shí)完成時(shí)被調(diào)用????

?

public abstract void onTick (long millisUntilFinished)

???????? 固定間隔被調(diào)用

參數(shù)

??????????????????????????? millisUntilFinished?? 倒計(jì)時(shí)剩余時(shí)間。

?

public synchronized final CountDownTimer start ()

???????? 啟動(dòng)倒計(jì)時(shí)

?

補(bǔ)充

文章精選

Android 定時(shí)器

android倒計(jì)時(shí)功能的實(shí)現(xiàn)(CountDownTimer

示例代碼

???????? Java

package com.test.countdowntimer;

?

import android.app.Activity;

import android.os.Bundle;

import android.os.CountDownTimer;

import android.util.Log;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.TextView;

?

import com.test.R;

?

public class CountDownTimeActivity extends Activity implements OnClickListener {

?

??? TextView mTextView;

??? Button mButton1;

??? Button mButton2;

???

??? @Override

??? protected void onCreate(Bundle savedInstanceState) {

?????? super.onCreate(savedInstanceState);

??????

?????? setContentView(R.layout.countdown);

??????

??? ??? mTextView = (TextView)findViewById(R.id.textView1);

?????? mButton1 = (Button)findViewById(R.id.button1);

?????? mButton2 = (Button)findViewById(R.id.button2);

?????? mButton1.setOnClickListener(this);

?????? mButton2.setOnClickListener(this);

??? }

?

??? CountDownTimer timer = new CountDownTimer(40000,1000) {

??????

?????? @Override

?????? public void onTick(long millisUntilFinished) {

?????????? mTextView.setText("seconds remaining: " + millisUntilFinished / 1000);

?????????? try {

????????????? Thread.sleep(1200);

?????????? } catch (InterruptedException e) {

????????????? e.printStackTrace();

?????????? }

?????????? Log.e("CountDown",millisUntilFinished+"");

?????? }

??????

?????? @Override

?????? public void onFinish() {

?????????? mTextView.setText("done!");

?????? }

??? };

???

??? @Override

??? public void onClick(View v) {

?????? switch(v.getId()){

?????? case R.id.button1:

?????????? timer.start();

?????????? break;

?????? case R.id.button2:

?????????? timer.cancel();

?????????? break;

?????? }

??????

??? }

}

?

?

???????? XML

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout

? xmlns:android="http://schemas.android.com/apk/res/android"

? android:orientation="vertical"

? android:layout_width="match_parent"

? android:layout_height="match_parent">

??? <TextView android:text="TextView" android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>

??? <Button android:text="開始" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>

??? <Button android:text="取消" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>

???

</LinearLayout>

?

說明:

CountDownTimer的間隔為1s,我們?cè)?/span>onTIck方法里面休眠了1.2s,所以log出來發(fā)現(xiàn)打印間隔變成了2s,即中間一次onTick方法沒有被執(zhí)行(不會(huì)在之前一次調(diào)用完成前被調(diào)用)。

?


Article précédent: Article suivant: