zoukankan      html  css  js  c++  java
  • 存储

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context="com.hanqi.zuoyee.cunchu_denglu">
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入账号"
        android:id="@+id/et1"/>
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="请输入密码"/>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center">
        <Button
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:text="登录"
            android:onClick="b1"/>
            <Button
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:text="注册"/>
    </LinearLayout>
    </LinearLayout>

    layout文件

    package com.hanqi.zuoyee;
    
    import android.content.SharedPreferences;
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    import android.view.View;
    import android.widget.EditText;
    
    public class cunchu_denglu extends AppCompatActivity {
        EditText et;
        String zh;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_cunchu_denglu);
            et=(EditText)findViewById(R.id.et1);
            SharedPreferences s=getSharedPreferences("a",MODE_PRIVATE);
            zh=s.getString("zhanghao",null);
            if(zh!=null){
                et.setText(zh);
            }
        }
        public void b1(View v){
            SharedPreferences s=getSharedPreferences("a", MODE_PRIVATE);
            SharedPreferences.Editor editor = s.edit();
           zh=et.getText().toString();
            if(zh.trim().length()==0){
                return;
            }
            editor.putString("zhanghao",zh);
            editor.commit();
    
        }
    }
  • 相关阅读:
    get 方式获取ajax
    javascript 面试题目
    原生js 制作选项卡切换效果
    js 回到顶部效果
    php mysql
    浏览器高度 clientHeight 与scrollHeight offsetHeight
    js dom中删除子节点removeChild
    Javascript综合笔记
    Ka贪心大暴走
    Openjudge NOI题库 ch0111/t1794 集合加法
  • 原文地址:https://www.cnblogs.com/storm47/p/5520388.html
Copyright © 2011-2022 走看看