本文整理匯總了Java中android.widget.Chronometer.setOnChronometerTickListener方法的典型用法代碼示例。如果您正苦於以下問題:Java Chronometer.setOnChronometerTickListener方法的具體用法?Java Chronometer.setOnChronometerTickListener怎麽用?Java Chronometer.setOnChronometerTickListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.Chronometer
的用法示例。
在下文中一共展示了Chronometer.setOnChronometerTickListener方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import android.widget.Chronometer; //導入方法依賴的package包/類
/**
* Called on create of the Activity. Sets up the activity
* with its layout. Also sets up and starts the chronometer to tick
* and check the time. If it's over 3 seconds it'll close.
*/
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.page_splash);
this.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
Chronometer chrono = (Chronometer) findViewById(R.id.chronometer_splash_chrono);
chrono.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
public void onChronometerTick(Chronometer chronometer) {
counter++;
if(counter > 2) {
Intent intent = new Intent(Splash.this, Main.class);
Splash.this.startActivity(intent);
Splash.this.finish();
}
}
});
chrono.start();
}
示例2: onCreate
import android.widget.Chronometer; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 防止鎖屏
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
mPath = getIntent().getStringExtra(VConstant.RECORD_VIDEO_PATH);
mCoverPath = getIntent().getStringExtra(VConstant.RECORD_VIDEO_CAPTURE);
if (StringUtils.isEmpty(mPath)) {
finish();
return;
}
setContentView(R.layout.activity_video_player);
mLoadingCircleView = (LoadingCircleView) findViewById(R.id.loadingView);
mLoadingCircleView.setProgerss(1, true);
mVideoView = (SurfaceVideoView) findViewById(R.id.videoview);
mPlayerStatus = findViewById(R.id.play_status);
// mLoading = findViewById(R.id.loading);
mChronometer = (Chronometer) findViewById(R.id.chronometer);
mChronometer.setOnChronometerTickListener(this);
mVideoView.setOnPreparedListener(this);
mVideoView.setOnPlayStateListener(this);
mVideoView.setOnErrorListener(this);
mVideoView.setOnClickListener(this);
mVideoView.setOnInfoListener(this);
mVideoView.setOnCompletionListener(this);
mVideoView.getLayoutParams().height = DeviceUtils.getScreenWidth(this);
findViewById(R.id.root).setOnClickListener(this);
if (mPath.startsWith("http")) {
downloadVideo(mPath);
} else {
mVideoView.setVideoPath(mPath);
}
}
示例3: onCreate
import android.widget.Chronometer; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.uistudy_clock);
final Button btn_tick = this.findButton(R.id.btn_tick);
final Chronometer ticker = this.findChronometer(R.id.tick_didadida);
//ticker.setFormat("");
btn_tick.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ticker.setBase(SystemClock.elapsedRealtime());
ticker.start();
btn_tick.setText("正在計時,等個5秒");
btn_tick.setEnabled(false);
}
});
ticker.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
@Override
public void onChronometerTick(Chronometer chronometer) {
long startTime = chronometer.getBase();
long now = SystemClock.elapsedRealtime();
long duration = now - startTime;
if(duration >= 5 * 1000){
chronometer.stop();
btn_tick.setText("開始計時");
showToast("時間到!淡定!");
btn_tick.setEnabled(true);
}
}
});
}
示例4: onCreate
import android.widget.Chronometer; //導入方法依賴的package包/類
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.game);
// create the score widget
LinearLayout score = (LinearLayout) findViewById(R.id.score);
_scoreview = new ScoreView(this);
score.addView(_scoreview);
// preferences
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
_sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
// remainder
_chrono = (Chronometer) findViewById(R.id.chrono);
_chrono.setOnChronometerTickListener(chronometerTickListener);
_rng = new Random();
// initialize game state
_gameMode = (GameMode)getIntent().getSerializableExtra(EXTRA_MODE);
if (savedInstanceState != null) {
_started = savedInstanceState.getBoolean(STATE_STARTED);
_elapsedTime = savedInstanceState.getLong(STATE_ELAPSEDTIME);
if (_started) {
_currentNote = savedInstanceState.getInt(STATE_CURRENTNOTE);
_nPresented = savedInstanceState.getInt(STATE_NPRESENTED);
_nCorrect = savedInstanceState.getInt(STATE_NCORRECT);
_nIncorrect = savedInstanceState.getInt(STATE_NINCORRECT);
_scoreview.setNote(_currentNote);
}
} else {
_started = false;
_elapsedTime = -1;
}
}
示例5: loadViews
import android.widget.Chronometer; //導入方法依賴的package包/類
/** 加載視圖 */
private void loadViews() {
setContentView(R.layout.activity_media_recorder);
// ~~~ 綁定控件
mSurfaceView = (SurfaceView) findViewById(R.id.record_preview);
mCameraSwitch = (CheckBox) findViewById(R.id.record_camera_switcher);
mTitleNext = (ImageView) findViewById(R.id.title_next);
mFocusImage = (ImageView) findViewById(R.id.record_focusing);
mProgressView = (ProgressView) findViewById(R.id.record_progress);
mRecordDelete = (CheckedTextView) findViewById(R.id.record_delete);
mRecordController = (ImageView) findViewById(R.id.record_controller);
mBottomLayout = (RelativeLayout) findViewById(R.id.bottom_layout);
mRecordLed = (CheckBox) findViewById(R.id.record_camera_led);
mImportVideo = (ImageView) findViewById(R.id.importVideo_btn);
mImportVideo.setOnClickListener(this);
mChronometer = (Chronometer) findViewById(R.id.chronometer);
mChronometer.setOnChronometerTickListener(this);
// ~~~ 綁定事件
if (DeviceUtils.hasICS()) {
mSurfaceView.setOnTouchListener(mOnSurfaveViewTouchListener);
}
mTitleNext.setOnClickListener(this);
findViewById(R.id.title_back).setOnClickListener(this);
mRecordDelete.setOnClickListener(this);
mBottomLayout.setOnTouchListener(mOnVideoControllerTouchListener);
// ~~~ 設置數據
//是否支持前置攝像頭
if (MediaRecorderBase.isSupportFrontCamera()) {
mCameraSwitch.setOnClickListener(this);
} else {
mCameraSwitch.setVisibility(View.GONE);
}
//是否支持閃光燈
if (DeviceUtils.isSupportCameraLedFlash(getPackageManager())) {
mRecordLed.setOnClickListener(this);
} else {
mRecordLed.setVisibility(View.GONE);
}
try {
mFocusImage.setImageResource(R.drawable.video_focus);
// mFocusImage.setVisibility(View.VISIBLE);
} catch (OutOfMemoryError e) {
Logger.e(e);
}
mProgressView.setMaxDuration(RECORD_TIME_MAX);
initSurfaceView();
}
示例6: TimeClock
import android.widget.Chronometer; //導入方法依賴的package包/類
public TimeClock(ComponentContainer container) {
super(container);
view = new Chronometer(container.$context());
view.setOnChronometerTickListener(this);
container.$add(this);
container.$form().registerForOnDestroy(this);
}