java - 在 android studio 中使用一个按钮在片段之间导航
问题描述
我正在 android studio 中开发一个应用程序(使用 Java),它需要在 3 个屏幕之间切换,直到它到达游戏。例如:
Screen A (user input and a question + button to continue) -> when pressing the button the input pass to the screen B
Screen B (user input and a question + button to continue) -> when pressing the button the input pass to the screen C
Screen C (user input and a question + button to continue) -> when pressing the button the input saved in DB and we start a new game.
这就像注册过程,但有多个屏幕。我的问题是如何使用片段来实现它?我认为由于屏幕是相似的(唯一改变的是问题)片段将是最好的选择。但是当我尝试实现它时,我没有成功让按钮在 3 个屏幕之间切换,只有 2 个。我还阅读了 ViewPager2,但是当我尝试使用它时发生了多个错误。另外,每个片段都需要保留前一个片段的输入+播放不同的记录。有没有什么好的实现来实现这个场景?
解决方案
推荐阅读
- c# - connectionString 中的错误:不支持关键字:“数据源”C# MVC web.config
- javascript - JavaScript,订购对象的功能
- java - 防止在 Spring Boot api 中下载文件
- codeigniter - Codeigniter 重定向组中的所有路由
- c++ - 编写一个程序,使用内置函数和用户定义函数计算 sin(x) 的值
- javascript - MongoDB 通过元素编号修改对象字段的数组,无需 findAndModify 或更新查询
- css - 无法使用网站的移动视图滚动
- python - 使用 python 向 JSON 文件添加新条目
- web-applications - 客户端-服务器场景的最佳 PayPal Web 应用程序工作流程是什么?
- reactjs - react-three-fiber 自定义着色器中的 WebGL 在道具更改或窗口调整大小时冻结