当前位置:网站首页>Use of checkbox
Use of checkbox
2022-04-22 10:18:00 【I can still size it.】
scene
When the user logs in for the first time , According to his choice, whether to save the password locally , And automatically fill in... The next time you open the application

resolvent
Use SharedPreferences Local storage
// Determine whether it is the first login
val prefs = getSharedPreferences("data",Context.MODE_PRIVATE)
val prefsEdit = getSharedPreferences("data",Context.MODE_PRIVATE).edit()
val isRemember = prefs.getBoolean("remember_password",false)
// Read previous password
if (isRemember){
Log.d("Login.out","isRemember = $isRemember")
val username = prefs.getString("account","")
val password = prefs.getString("password","")
loginBinding.usernameEdit.setText(username)
loginBinding.passwordEdit.setText(password)
loginBinding.rememberPass.isChecked = true
}
Use checkbox

To set up checkbox Click to listen for events !!
Then judge whether he was elected
loginBinding.rememberPass.setOnClickListener {
// The user chooses to remember the password Save the user name and password locally
if (loginBinding.rememberPass.isChecked){
Log.d("Login.out","isRememberPass = $isRemember")
prefsEdit.putBoolean("remember_password",true)
prefsEdit.putString("account",loginBinding.usernameEdit.text.toString())
prefsEdit.putString("password",loginBinding.passwordEdit.text.toString())
prefsEdit.apply() // Don't forget this sentence
}
}
版权声明
本文为[I can still size it.]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221005377028.html
边栏推荐
- DPU 芯片头部企业云豹智能加入 openEuler社区,为数字中国基础设施助力
- *CTF 2022 Reverse Writeup
- Text justify, orientation, combine text attributes
- linux安装oracle19c完整版(图形+静默安装)
- Film online ticket purchase system based on SSM
- TIANTI 22 analog l3-2 puzzle a punch in reward (30 points)
- Usage of stringstream
- Nacos
- Glide设置圆角图片(支持自定义圆角位置)
- Laya Uncaught ReferenceError: spine is not defined
猜你喜欢

Oracle 如何使用循环控制关键字exit、goto、continue

Matplotlib tutorial 04 --- drawing commonly used graphics

Laya Uncaught ReferenceError: spine is not defined

企业级 Web 开发的挑战

最通俗易懂的依赖注入之服务容器与作用域

Memory management-

Film online ticket purchase system based on SSM

Windows下oracle11.2.0.1升级至oracle11.2.0.4

5.嵌入式控制器(Embedded Controller,EC)学习 PS/2协议

Linux Installation Oracle 19C Full Version (graphics + silent installation)
随机推荐
天梯22模拟 L3-2 拼题A打卡奖励 (30 分)
获取浏览器网址 地址
LC301. Remove invalid parentheses
Oracle 如何使用循环控制关键字exit、goto、continue
Challenges of enterprise web development
MySQL multi instance installation method I
UKUI3 支持 openEuler 22.03 LTS
[SQL Server] SQL overview
Swoole high performance in memory database use and configuration tutorial
头条面试居然跟我扯了半小时的Semaphore
SQL operator
中商惠⺠交易中台架构演进:对 Apache ShardingSphere 的应⽤
DataGuard (ADG) spare database moves (migrates) data files
Golang time strings common methods
The headline interview actually told me about semaphore for half an hour
多目标追踪——拓展卡尔曼滤波(EKF)
【濡白的C语言】初学者-从零开始-5(模块化设计——函数,传值和传址)
Ukui3 supports openeuler 22.03 LTS
HAS2022 | 第19届华为全球分析师大会即将启幕!
*CTF 2022 Reverse Writeup