zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    redis概要学习
    http协议格式详解
    浅谈mysql
    linux常用命令
    Linux 程序管理
    认识与分析日志文件
    认识与学习bash
    例行任务管理
    软件安装的三大方法
    关于一些感慨
  • 原文地址:https://www.cnblogs.com/zhang1107/p/3115323.html
Copyright © 2011-2022 走看看