一个HelloWorld,启动以后,看到"HelloWorld"字样,当你在模拟器点其它按钮,切到其它画面后,再也回不到"HelloWorld"字样的界面了。是不是程序就像是C环境下的控制台程序,main已经return结束了?
另外,我将res/layout/main.xml修改了一下,多了两个Edit,一个按钮。很明显,它需要停在此界面上,等待用户输入输出。一直不理解,android程序启动后,如果说没有结束,那模拟器如何再找回?
如果说结束了,又如何得知?<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="身高(cm)"
/>
<EditText android:id="@+id/height"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:numeric="integer"
android:text=""
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="体重(kg)"
/>
<EditText android:id="@+id/height"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:numeric="integer"
android:text=""
/>
<Button android:id="@+id/submit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="计算 BMI 值"
/>
<TextView android:id="@+id/result"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
/>
<TextView android:id="@+id/suggest"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
/>
</LinearLayout>
另外,我将res/layout/main.xml修改了一下,多了两个Edit,一个按钮。很明显,它需要停在此界面上,等待用户输入输出。一直不理解,android程序启动后,如果说没有结束,那模拟器如何再找回?
如果说结束了,又如何得知?<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="身高(cm)"
/>
<EditText android:id="@+id/height"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:numeric="integer"
android:text=""
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="体重(kg)"
/>
<EditText android:id="@+id/height"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:numeric="integer"
android:text=""
/>
<Button android:id="@+id/submit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="计算 BMI 值"
/>
<TextView android:id="@+id/result"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
/>
<TextView android:id="@+id/suggest"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
/>
</LinearLayout>
解决方案 »
- 用手机调试安卓程序,一连手机就不停的报很多错误,怎么解决
- start called in state 1 报这个错。 以下是代码
- Android 跨域请求同时通过windows身份验证?
- 服务器端向Android客户端返回数据显示
- 小弟初学android,但没有参考书籍,求答复啊
- Activity 回收
- android native code 多线程如何调试?
- 关于android背景设置问题
- 菜鸟求助 环信 Unknown Source
- 求助 基于android的俄罗斯方块速度处理问题
- 疑惑: Camera这个类也是继承了BnCameraClient,所以它可以做一个服务,而他的客户端访问在什么地方呢 ?
- 本人的毕业设计,急!!!
一般一个界面对应一个activity 如果你退出没将这个activity finish掉的话,activity仍保存在堆栈中,还可以返回到该界面。
如果自己想结束程序,activity可以调用finish,也可以执行System.exit(0); 或者android.os.Process.killProcess(android.os.Process.myPid())Android程序完全退出的三种方法一般情况,按back键退出的话,再次进入程序就是从头开始执行的。
按home键或者挂机键,应用就不会结束,会返回到上次的画面。
因为系统会回调onDestroy()函数