请教,如何从onPause到onResume 请教,如何从onPause到onResumeDOC上有一个ACTIVITY的生命周期的图,,其中有从onPause到onResume的状态改变,,如何才可以从onPause下一步直接触发onResume事件呢???请给代码:,帮忙啊, 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 那你需要看activity的源码了。是系统触发的事件,将activity置回top package test.run;import android.app.Activity;import android.app.AlertDialog;import android.os.Bundle;import android.util.Log;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;public class Index extends Activity { private static final String TAG = "IndexActivity"; @Override protected void onStart() { super.onStart(); Log.v(TAG, "protected void onStart()"); } @Override protected void onPause() { super.onPause(); Log.v(TAG, "protected void onPause()"); } @Override protected void onResume() { super.onResume(); Log.v(TAG, "protected void onResume()"); } @Override protected void onStop() { super.onStop(); Log.v(TAG, "protected void onStop()"); } @Override protected void onDestroy() { super.onDestroy(); Log.v(TAG, "protected void onDestroy()"); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Log.v(TAG, "public void onCreate"); Button button1 = (Button) this.findViewById(R.id.button1); button1.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { new AlertDialog.Builder(Index.this).setTitle("标题").setMessage( "简单消息框").setPositiveButton("确定", null).show(); } }); }}不触发onPause事件啊,怎么办,点击按钮也不行, 按home键 不只是调用onpause 还会调用onstop 所以没法直接跳到onresume直接从onpause到onresume的情况比如 弹出一个对话框, 但此时主activity还是可见的,只调用onpause 从对话框返回后 再调用onresume TO jxnktjlfr1上面的代码就是弹出对话框,但还是不执行onPause事件,, 启动你的界面后,按back就会进onPause了 dinjay 按BACK不光ONPAUSE了,还ONSTOP了,我不想ONSTOP 我的问题也就是如何重现DOC中的ONPAUSE到ONRESUME的效果 我试了下 我弹出的对话框是activity的 就是activity 设置成android:theme="@android:style/Theme.Dialog" 这样弹出对话框后确实只调用了 onpause 之后再按返回键 再调用的 onresume (注意一定要按返回键,如果你在弹出的对话框中有什么操作比如输入或单击一个button之类的话,这时还会调用onstop ,因为焦点已经转移到了对话框) andorid开发文档上就有啊!http://blog.csdn.net/Android_Tutor/article/details/5789203 希望对你有用 虚拟器出问题了 简述Android触摸屏手势识别2 在android上有什么方法可以在不用java的情况下调用摄像头,比如js,html,silverlight Android开发中能不能把模拟器和开发环境分别装在不同的机器上?? Android上如何创建一个UI android中没法获取本机号 android 搜索功能(txt,pdf,word) 新手问题,关于Id查找 activity的跳转问题 使用百度地图时出现的问题 listview不处发onTouch事件,好像是要配一个什么属性? 刚初学安卓·好多书·不知道啥书好..
import android.app.AlertDialog;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;public class Index extends Activity { private static final String TAG = "IndexActivity"; @Override
protected void onStart() {
super.onStart();
Log.v(TAG, "protected void onStart()");
} @Override
protected void onPause() {
super.onPause();
Log.v(TAG, "protected void onPause()");
} @Override
protected void onResume() {
super.onResume();
Log.v(TAG, "protected void onResume()");
} @Override
protected void onStop() {
super.onStop();
Log.v(TAG, "protected void onStop()");
} @Override
protected void onDestroy() {
super.onDestroy();
Log.v(TAG, "protected void onDestroy()");
} @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.main); Log.v(TAG, "public void onCreate"); Button button1 = (Button) this.findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
new AlertDialog.Builder(Index.this).setTitle("标题").setMessage(
"简单消息框").setPositiveButton("确定", null).show();
}
}); }
}不触发onPause事件啊,怎么办,点击按钮也不行,
上面的代码就是弹出对话框,但还是不执行onPause事件,,
之后再按返回键 再调用的 onresume (注意一定要按返回键,如果你在弹出的对话框中有什么操作比如输入或单击一个button之类的话,这时还会调用onstop ,因为焦点已经转移到了对话框)