zoukankan      html  css  js  c++  java
  • sp记住账户名

    package com.example.lenovo.lianxiyong;

    import android.content.SharedPreferences;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;
    import android.widget.Toast;

    public class JizhuzhanghaoActivity extends AppCompatActivity {

    EditText et1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_jizhuzhanghao);

    et1=(EditText)findViewById(R.id.et1);

    SharedPreferences sp=getSharedPreferences("a",MODE_PRIVATE);

    String s=sp.getString("a",null);
    et1.setText(s);
    }

    public void bt1(View v)
    {
    String string=et1.getText().toString();
    SharedPreferences sharedPreferences=getSharedPreferences("a",MODE_PRIVATE);

    SharedPreferences.Editor editor=sharedPreferences.edit();

    editor.putString("a",string);

    editor.commit();

    Toast.makeText(JizhuzhanghaoActivity.this, "记住账户", Toast.LENGTH_SHORT).show();
    }
    }


    
    
  • 相关阅读:
    CODE[VS] 2506 可恶的体育老师
    CODE[VS] 3411 洪水
    CODE[VS] 2692 小明过生日
    CODE[VS] 2291 糖果堆
    CODE[VS] 2008 你已经爱我多久了
    忽然之间
    Amazing grace 奇异恩典
    无处安放
    AC日记
    AC日记
  • 原文地址:https://www.cnblogs.com/1ming/p/5522251.html
Copyright © 2011-2022 走看看