简体   繁体   English

Android-将日期从一个片段添加到另一个正在运行的片段

[英]Android - add date from one fragment to another running fragment

I have 2 Fragments, A and B 我有2个片段,A和B

A is already running and has edittexts and data filled out. A已在运行,并且已填充了edittext和数据。

There is a button in A that opens fragment B A中有一个按钮可以打开片段B

fragment B is a list of pictures 片段B是图片列表

I need to select a picture from B and send it back to A where it is set as an imageview. 我需要从B中选择一张图片,然后将其发送回A并在其中设置为imageview。

how do I do this with out loosing all the data already filled out in A. 如何在不丢失A中已经填写的所有数据的情况下做到这一点。

尝试Fragment.setTargetFragment和Fragment.getTargetFragment

Use onSaveInstanceState http://developer.android.com/reference/android/app/Fragment.html#onSaveInstanceState(android.os.Bundle) 使用onSaveInstanceState http://developer.android.com/reference/android/app/Fragment.html#onSaveInstanceState(android.os.Bundle)

Check out this thread if you're still having problems saving the states in fragments. 如果您仍然无法将状态保存在片段中,请查看此线程。 Fragment's onSaveInstanceState() is never called 片段的onSaveInstanceState()永远不会被调用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM