第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何停止“倒數(shù)計時器”并在 Android Studio 的對話框中顯示結果?

如何停止“倒數(shù)計時器”并在 Android Studio 的對話框中顯示結果?

拉風的咖菲貓 2021-07-02 10:03:06
因為我是 android 開發(fā)的新手,所以我需要一些幫助。我正在開發(fā)測驗應用程序,所以我有分數(shù)倒計時。我無法弄清楚如何停止計時器并在自定義對話框中顯示。因此,如果每個問題都將完成,則應停止計時器,并且必須在最后一次對話中。在我將它存儲到數(shù)據(jù)庫中以按時間和分數(shù)對其進行排序之后。這里是倒計時方法。private void countD(){        countDownTimer = new CountDownTimer(timeleftinmilliseconds, 1000) {            @Override            public void onTick(long l) {                timeleftinmilliseconds = l;                int minutes = (int) (timeleftinmilliseconds/1000)/60;                int second = (int) (timeleftinmilliseconds/1000)%60;                String timeletfFormated  = String.format(Locale.getDefault(), "%02d:%02d", minutes, second);                timetext.setText(timeletfFormated);            }            @Override            public void onFinish() {                timetext.setText("00:00");            }        }.start();自定義對話框的xml<TextView    android:id="@+id/dialog_time_message"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:text="Your Time is: "    android:layout_below="@id/dialog_message"    android:textSize="18dp"    android:layout_marginTop="20dp"    /><TextView    android:id="@+id/dialog_time_score"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:layout_toRightOf="@id/dialog_message"    android:paddingLeft="10dp"    android:text="00:00"    android:textSize="18dp"    android:layout_marginTop="20dp"    android:layout_below="@+id/dialog_score"    /><EditText    android:id="@+id/edittext_name"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:hint="Please enter your name"    android:layout_below="@+id/dialog_time_message"    android:layout_marginTop="10dp"    />
查看完整描述

2 回答

?
牛魔王的故事

TA貢獻1830條經(jīng)驗 獲得超3個贊

您可以使用 cancel() 方法:


private CountDownTimer countDownTimer;


public void startCount(){


countDownTimer = new CountDownTimer(SECONDS_TO_DISMISS, 1000) {


            @Override

            public void onTick(long time) {

               strong text

            **strong text**

            }


            @Override

            public void onFinish() {


            }


        }.start();

}


public void stopCount(){

    countDownTimer.cancel();

}


查看完整回答
反對 回復 2021-07-07
  • 2 回答
  • 0 關注
  • 286 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號