Activity生命周期

Log类对错误的排查:示例代码

private final static String TAG = "MainActivity"; //宏定义
Log.i(TAG,"MainActivity---->OnCreate");    //排错
View Code

 Activity 的save保存

宏定义:    private static final String CONTENT = "content";
OnCreate中添加EditText的判断条件:
txt=(EditText)findViewById(R.id.txt);
        if(null==savedInstanceState && savedInstanceState.containsKey(CONTENT)) {
                txt.setText(savedInstanceState.getString(CONTENT));
        }

创建Save函数:
    @Override
    protected void onSaveInstanceState(Bundle outState) {
        // TODO Auto-generated method stub
        super.onSaveInstanceState(outState);
        String content=txt.getText().toString();
        outState.putString(CONTENT, content);
    }
这部分代码在虚拟机上运行会出现错误,需要一个具有android系统的手机。
View Code

android:theme显示连接

android:theme="@android:style/Theme.Dialog"//显示为对话框
android:theme="@android:style/Theme.NoTitleBar"//没有标题
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:theme="@android:style/Theme.Light.NoTitleBar"
android:theme="@android:style/Theme.Wallpaper" 
android:theme="@android:style/Theme.Translucent"//背景透明化
android:theme="@android:style/Theme.Panel" //无标题背景透明化
View Code

在AndroidManifest.xml中新建的Activity中加入如下的一句话可以把其变成对话框的形式.

 android:theme="@android:style/Theme.Dialog"
View Code
原文地址:https://www.cnblogs.com/zhang1107/p/3115323.html