gpt4 book ai didi

android - 如果选中复选框,则启动另一个 Activity

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:51:29 25 4
gpt4 key购买 nike

当我的应用程序启动时,会出现登录 Activity 。它包含复选框“下次给我签名”。我想在下次启动应用程序时启动另一个 Activity ,如果选中复选框,则将用户的用户名和密码发送给它。

我该如何实现?

最佳答案

您可能希望在 SharedPreferences 中保存用户名和复选框值。之后,您可以在应用程序启动时检索它们。

例子:

//Saving the values
SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("username",username);
editor.putString("password",password);
editor.putBoolean("isChecked", isCheckBoxChecked);
editor.commit();

//Retrieving the values
SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE);
if(sharedPreferences.getBoolean("isChecked"))
{
//Do whatever you need to do if it's checked
}

关于android - 如果选中复选框,则启动另一个 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12051017/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com