【问题标题】:How to share Button's status from one activity to another activity如何将 Button 的状态从一个活动共享到另一个活动
【发布时间】:2021-11-19 13:36:59
【问题描述】:
  • 假设活动 1 中有 3 个按钮,单击每个按钮 颜色变化以及文字。
  • 我想使用 sharedpreference 保存这两个值。
  • 比在 2 个活动中获取这些值。
  • 然后我们会检查按钮是否被点击,按钮颜色和文字是否发生变化。
  • 如果已更改,则显示 2 个按钮,否则显示文本。

【问题讨论】:

    标签: java android android-studio android-layout sharedpreferences


    【解决方案1】:

    如果您将两个值都保存在 sharedpreference 中,那么您可以直接在第二个活动中使用它

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-17
      • 2011-10-27
      • 2012-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多