点击CheckBox记住密码
来源:互联网 发布:mac ssh工具 编辑:程序博客网 时间:2024/05/15 04:40
首先写一个轻量级存储
<pre style="font-family: 宋体; font-size: 10.8pt; background-color: rgb(255, 255, 255);">SharedPreferences sharedPreferences = getSharedPreferences("YongHu",MODE_PRIVATE);
先把你出入的用户名和密码存储到(sharedPrefrences)
String strJudge = sharedPreferences.getString("setJudge", "no"); String strUserName = sharedPreferences.getString("strUserName", ""); String strPassWord = sharedPreferences.getString("strPassWord", ""); if (strJudge.equals("yes")){ box.setChecked(true); name.setText(strUserName); pass.setText(strPassWord); }else { box.setChecked(false); name.setText(""); pass.setText(""); }
最后点击CheckBox记住密码
box.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(isChecked == true){//勾选时,存入EditText中的用户名密码 sharedPreferences.edit().putString("setJudge", "yes") .putString("strUserName", name.getText().toString()) .putString("strPassWord", pass.getText().toString()) .commit(); Toast.makeText(RegisterActivity.this, "记住用户名和密码", Toast.LENGTH_SHORT) .show(); }else{//不勾选,存入空String对象 sharedPreferences.edit().putString("setJudge", "no") .putString("strUserName", "") .putString("strPassWord", "") .commit(); Toast.makeText(RegisterActivity.this, "不记住用户名和密码", Toast.LENGTH_SHORT) .show(); } } });
希望对你有所帮助
1 0
- 点击CheckBox记住密码
- 点击CheckBox复选框是否记住密码
- 安卓开发点击CheckBox记住密码
- CheckBox记住密码功能
- 登录界面CheckBox记住密码
- 点击checkbox保留账号和密码
- 记住密码
- 记住密码
- 记住密码
- 记住密码
- 记住密码
- 记住密码
- 记住密码
- 记住密码
- 记住密码
- 记住密码
- 记住密码
- 记住密码
- 怎样设置CorelDRAW中的网格参数
- ViewPager+Fragment自定义View滑动条
- stm32下f4的adc_dma采集
- 调试 调试 debug
- 机器学习防止过拟合之L1范数(正则)与LASSO
- 点击CheckBox记住密码
- Redis之对key的操作
- appium for windows 环境搭建
- Linux下压缩与解压命令
- 手动释放linux内存cache和脚本定时释放
- 【原创】【NOIP】文化之旅
- 将截断字符串或二进制数据
- Map集合遍历的四种方式
- Redhat7使用yum安装Oracle 11g快速安装