zhuceActivity
package com.example.tiwenzhuce; import androidx.appcompat.app.AppCompatActivity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; import java.util.Map; public class zhuceActivity extends AppCompatActivity { private EditText mEtUserName;//声明空间 private EditText et_1; private EditText et_2; private String strname; private String strpasswd; private SharedHelper sh; private Context mContext; private Button mBtnzhuce2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); mContext = getApplicationContext(); sh = new SharedHelper(mContext); et_1 = findViewById(R.id.et_1); et_2 = findViewById(R.id.et_2); mBtnzhuce2 = findViewById(R.id.btn_zh_2); mBtnzhuce2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { strname = et_1.getText().toString(); strpasswd = et_2.getText().toString(); sh.save(strname, strpasswd); Toast.makeText(zhuceActivity.this, "注册成功!", Toast.LENGTH_SHORT).show(); Intent it = new Intent(zhuceActivity.this, TiWenzhuce.class); zhuceActivity.this.startActivity(it); } }); } }