我正在创建一个名为电子衣柜的应用程序,用户将填写一些输入信息,如“布类型”,“季节”,“颜色”等。例如,当用户将冬天写入季节字段时,该应用会将类型和颜色字符串传递到WinterActivity中,但我不知道如何执行此操作。我希望你会帮助我,thanx提前:)Android:在活动间传递数据
-4
A
回答
0
你可以检查季节字段,然后确定什么活动从该字段开始,然后将你想传递的其他信息与它一起作为一个捆绑意图。或者更好的做法是不做一个冬季活动只是做一个SeasonActivity,只是传递所有其他信息,然后让活动决定它需要什么样子以及它应该与用户分享哪些数据。
从A传送的数据 - > B在意图
而是从A - > B(对话框或第二步骤) - >经由ActivityForResult
+0
最好让它OP在给出整个解决方案之前展示了一些努力。 –
+1
没有给出任何代码帮助:)只是理论。如果他们有他们编写并需要帮助的代码,我将永远不会帮助他们 –
0
做你需要束数据添加到这样
//create the intent and bundle
Intent launchIntent = new Intent(
MenuActivity.this, com.you.AnotherActivity.class);
Bundle extraData = new Bundle();
//assign some values to the bundle
extraData.putSerializable("key1", "value");
//assign bundle to launchIntent
launchIntent.putExtra("keyBundle", extraData);
//start the activity
startActivity(launchIntent);
推出的意图,然后检索中的其他活动的数据是这样的:
//create a new intent to put the one that started this activity
Intent intent = getIntent();
//retrieve the bundle that was sent in the intent
Bundle recievedBundle =
intent.getBundleExtra("keyBundle");
//get the bundle passed from the activity that started this one
MyVariableInAnotherActivity = recievedBundle.getSerializable("key1");
0
试试这个:
Intent intent = new Intent(CurrentActivity.this, WinterActivity.class);
intent.putExtra("cloth", clothTextField.getText().toString());
intent.putExtra("color", colorTextField.getText().toString());
startActivity(intent);
在冬季活动收到他们喜欢:
String cloth = getIntent().getStringExtra("cloth");
String color = getIntent().getStringExtra("color");
希望它可以帮助!
相关问题
- 1. 在Android活动之间传递数据
- 2. Android在活动之间传递数据
- 3. 在活动之间传递数据
- 4. 在活动之间传递数据
- 5. 活动之间传递整数值 - Android
- 6. Android应用数据实现/活动间传递数据
- 7. Android在活动之间传递变量
- 8. 在Android中的活动之间传递数据?
- 9. Android - 在两个活动之间传递数据获取NullPointerException
- 10. 如何在Android中的活动之间传递数据?
- 11. 在Android中的活动之间传递数据
- 12. Android:在服务和活动之间传递数据
- 13. 在活动之间传递数据 - Android SDK
- 14. 如何在活动之间传递数据库对象(Android)
- 15. 如何在android中的两个活动之间传递数据?
- 16. 在活动Android |之间传递数据java
- 17. Xamarin的数据传递活动之间
- 18. 在活动之间切换活动/传递数据
- 19. 活动数据传递Android Xamarin
- 20. android传递数据新活动
- 21. 如何在列表活动和Android下载活动之间传递数据
- 22. Android活动之间的数据传输
- 23. 如何在活动之间保存数据并传递数据
- 24. 2个活动之间传递数据android
- 25. 传递数据与活动之间的事件标签 - Android
- 26. 在Android中的活动之间传递数据(BIG JSON数据字符串)
- 27. Android之间传递protobuf活动
- 28. 在Android中传递整数活动
- 29. Android:如何在活动之间传递整数数组?
- 30. 在Android活动之间高效地传递自定义对象数据[Mono Android]
你有没有在谷歌搜索标题?你会发现许多很多示例代码和教程。 –
你甚至打扰Google搜索吗?搜索'intent.putExtra'开始。 –
是的,我做了,我尝试了一些东西,但他们没有工作。 :( – user3676303