how to change format of chronometer?

后端 未结 7 2339
攒了一身酷
攒了一身酷 2020-12-14 18:25

One of my problem is of changing the format of chronometer in android. i have the problem that chronometer shows its time in 00:00 format and i want it to come in 00:00:00 f

7条回答
  •  醉酒成梦
    2020-12-14 19:13

    // You can use this code. Setting the format and removing it
    //Removing the format (write this in oncreate)
    if (mChronometerformat) {
        mSessionTimeChro.setOnChronometerTickListener(new OnChronometerTickListener() {
            @Override
            public void onChronometerTick(Chronometer chronometer) {
                if (chronometer.getText().toString()
                        .equals("00:59:59"))
                    chronometer.setFormat(null);
    
            }
        });
    }
    // Setting the format
    mSessionTimeChro.setBase(SystemClock.elapsedRealtime());
    if (diffHours == 0) {
        mSessionTimeChro.setFormat("00:%s");
        mChronometerformat = true;
    }
    mSessionTimeChro.start();
    

提交回复
热议问题