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();
}
}
![](https://images2015.cnblogs.com/blog/884524/201605/884524-20160524090715209-278426360.png)
![](https://images2015.cnblogs.com/blog/884524/201605/884524-20160524090745756-1912484742.png)