
在我的程序中,您在secondActivity中设置倒数计时器的字符串值.然后将该值发送到MainActivitIEs textVIEw,然后应该在获取值后立即开始倒计时.现在我已经设置了所以你可以设置值,并且正确获取值,但是我不知道该怎么做是在收到它时开始倒数这个值.我已经制作了一个CounterClass.
这是我的MainActivity Code …
Bundle extras = getIntent().getExtras(); String intentString; if(extras != null) { intentString = extras.getString("TimeValue"); timer = new CounterClass(60000, 1000); timer.start(); timeSent(); } else { intentString = "Default String"; } textTime= (TextVIEw) findVIEwByID(R.ID.timeText); textTime.setText(intentString);解决方法:
你需要启动你的计时器.总是read the docs.
timer = new CounterClass(millisInFuture, countdownInterval);timer.start();编辑
millisInFuture — The number of millis in the future from the call to start() until the countdown is done and onFinish() is called.
countDownInterval —
The interval along the way to receive onTick(long) callbacks.
编辑18-12-2015
将您的intentString转换为millisInFuture并将其发送到CounterClass.然后在onTick()方法中将其格式化为HH:MM.
String time = "16:54";String split[] = time.split(":");long futureInMillis = Integer.parseInt(split[0]) * 60 * 60 * 1000 + Integer.parseInt(split[1]) * 60 * 1000; 总结 以上是内存溢出为你收集整理的java – 从SecondActivity接收MainActivity中的字符串值,然后将其向下计数全部内容,希望文章能够帮你解决java – 从SecondActivity接收MainActivity中的字符串值,然后将其向下计数所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)