问题标签 [chronometer]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
480 浏览

android - 更改 xml 使我的应用程序崩溃

所以我的秒表类运行良好,直到我对它的 XML 代码进行了一些更改。基本上我所做的是改变一些尺寸和 layout_margins..没什么特别的

继承人的xml代码和logcat

这是日志猫

这是这个活动的java代码

0 投票
1 回答
1479 浏览

java - 计时器的值成字符串

我正在尝试将计时器的值相乘,或者只是尝试将值设为字符串。

每次我尝试将其设为字符串并用于toast.show()查看它时,我的应用程序都会崩溃。我可以EditText显示我的价值,但我似乎无法让我的计时器工作。两个字符串timefin让它崩溃。这是代码:

0 投票
1 回答
364 浏览

android - Method call - onActivityResult vs DialogInterface.OnClickListener()

I just published a game on the Play Store and am planning to make it look better and more intuitive, si I'm trying to replace the Android dialogs by mines.

When the user finish a level, I need my custom dialog to show and if the user clicks some buttons, the dialog (which is an activity with a custom theme that make it looks like a dialog) have to return an integer with setResult(customResult, intent) and then finish.

The problem is that when I receive the resultCode in the onActivityResult() of the activity that did startActivityForResult(intentCustomDialog, 0), I call a custom method that restart the level or launch the next one depending on the result (used to know what button the user clicked). This methods should also restarts the Chronometer, but it does nothing !!!!!!!
On the other side when I use the android dialog and I put the restart() call in the onClickListener the chronometer is successfully restarted !?

So what am I missing ? Why the restart() call successfully restart the chronometer with an onClickListener of the android dialogs but not when I call it from the onActivityResult() method ?

Would be very helpful so I could make my own dialogs implementation and use the onActivityResult() or even call a custom onDialogResult() method to separate startActivityForResult() launches of custom dialogs activities and normal activities.

Thanks in advance.

EDIT

In my game class :

restartGrid() method :

Works perfectly from a DialogInterface.OnClickListener().

0 投票
1 回答
487 浏览

android - Android Chronometer:更改视图时停止 - 保存状态?

我通过 ActionBarSherlock 获得了一个 ActionBar,但是当我从计时选项卡切换到另一个选项卡时。它停止并回到 0。当我最小化应用程序时它不会停止......

我需要什么来保存状态?我正在使用 4 按钮来启动、停止、恢复和重新启动...

提前致谢!

0 投票
0 回答
1117 浏览

android - 带有 Chronometer 的 AsyncTask 示例

我有一个 Chronometer,但是当我改变我的视图(使用 ActionBar)时它会停止。

我不是很了解如何使用 AsyncTask,也没有找到教程。

有什么容易解决我的问题吗?我真的很想举一个Chronometer的例子......

非常感谢!

到目前为止的代码:

我刚刚复制了代码......(Chrono 工作,但不在后台)

0 投票
1 回答
356 浏览

android - Android:天文台计数真的很快

这是我的代码:

如果用户真的很快(几乎一起)按下开始/暂停,那么计时码表会快速计数并跳过几秒钟......它不会停止,直到按下暂停然后它再次正常工作?为什么会这样以及如何预防?

谢谢!

0 投票
1 回答
629 浏览

eclipse - 在 Eclipse 中创建 01:00 倒数计时器(计时器)

我在我的 Android 应用程序中实现了一个 Chronometer 对象。创建 01:00 倒数计时器的简单代码是什么,让用户有 1 分钟时间完成当前关卡?

0 投票
0 回答
1987 浏览

android - 获取视图中显示的计时器的值

我正在使用计时器在我的 android 应用程序中显示时间。

我想获取屏幕上显示的计时器值。我试着用

并获得我使用的价值long elapsedMillis = SystemClock.elapsedRealtime() - chronometer.getBase();

它对我来说显示了一个特定的数字,它看起来不像屏幕上显示的时间。如果屏幕上的计时器显示 1 秒,我想得到精确的 1 秒而不是任何随机数。

有没有人可以帮我解决这个问题?

0 投票
2 回答
197 浏览

android - 无法从 View 投射到 Chronometer

我做的一切都是对的,我猜?我保存了 xml 文件,但不知道如何解决这个问题。我是新手,请帮助。

这是我的xml代码:

chronometer.java:

0 投票
5 回答
7009 浏览

java - 计时器简历?

当我点击开始时,'秒表'开始计数..我按下暂停,只有 textview 暂停,它没有恢复,因为它仍在后台运行..我需要它在我停止的地方恢复..

这是我的点 java 代码: