本文整理汇总了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);
}