比如点击一个按钮,判断一下计时器当前的状态,如果计时器正在运行,就停止计时。如果计时器停止,就开始计时运行
解决方案 »
- Android开发实现显示Pdf文件
- 在重载的onmearsure函数中如何得到其他view的高
- 我需要编一个与服务器通信的客户端
- android代码又错了,求救!!!
- android google maps中定位功能,在线等
- ■★Android流行的浏览器的区别■★
- 是否可以不用安装apk,直接用真机仿真?
- 跪求authoware简历
- Android Eclipse中现有项目Ctrl+鼠标左键没办法使用,还有Graphical Layout没办法显示。
- 如何在Android JNI编程中实现对信号量的操作?
- 谁帮我看看我这个android端连接无线那里出错了
- 如何连接指定mac地址的wifi
private boolean running = false;
private String lastTime;@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.main); final Chronometer chrono = (Chronometer) findViewById(R.id.chrono);
Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new OnClickListener() { @Override
public void onClick(View v) {
if(running) {
chrono.start();
}
else {
lastTime = chrono.getText().toString();
chrono.stop();
}
running = !running;
}
});
}
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="fullScreen"
android:text="Click" /> <Chronometer
android:id="@+id/chrono"
android:layout_width="wrap_content"
android:layout_height="wrap_content" /></LinearLayout>