Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的应用程序需要有多个屏幕,例如一个登录页面,然后是另一个显示项目列表的页面,然后是显示所选项目详细信息的页面。我想知道在这种情况下一般/公认的做法是什么?我怀疑它会有多个布局,但我如何存储已选择的项目。
您在活动之间传递它,有多种方法可以做到这一点。最简单的简单项目是在 Intent 中传递它们
关于活动 A:
... intent.putExtra("selectedItem", "1"); startActivity(intent);
关于活动 B:
Intent intent = getIntent(); String item = intent.getStringExtra("selectedItem");