package com.example.wang.myapplication;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
public class ZuoyeActivity5 extends AppCompatActivity {
EditText user_name;
EditText user_password;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_zuoye5);
user_name=(EditText)findViewById(R.id.user_name);
user_password=(EditText)findViewById(R.id.user_password);
SharedPreferences sharedPreferences1 =getSharedPreferences("cunchu",MODE_APPEND);
String string = sharedPreferences1.getString("用户名", "未添加");
Log.e("TAG","string="+string);
user_name.setText(string);
}
public void bt1_OnClick(View v)
{
String username=user_name.getText().toString();
String userpassword=user_password.getText().toString();
SharedPreferences sharedPreferences=getSharedPreferences("cunchu", MODE_APPEND);
SharedPreferences.Editor editor=sharedPreferences.edit();
editor.putString("用户名",username);
editor.putString("用户密码", userpassword);
editor.commit();
Log.e("TAG","username="+username);
Log.e("TAG", "userpassword="+userpassword);
}
public void bt2_OnClick(View v)
{
finish();
}
}