我有一些问题想要询问有关在活动中将数据从片段传递到片段的问题。我不知道该怎么做。有人可以帮忙吗? 这是我的代码。
ShareFragment.java
@XmlRootElement(name = "SrvPutBusinessOperationEventNf")
@XmlAccessorType(XmlAccessType.FIELD)
public class BusinessOperationEvent {
@XmlElement(name = "RqUID")
private String rqUID;
@XmlElement(name = "RqTm")
private String rqTm;
@XmlElement(name = "sPName")
private String sPName;
@XmlElement(name = "SystemId")
private String systemId;
@XmlElement(name = "Method")
private String method;
@XmlElement(name = "BusinessProcess")
private String businessProcess;
@XmlElement(name = "Operation")
private String operation;
@XmlElement(name = "Step")
private String step;
@XmlElement(name = "SourceModule")
private String sourceModule;
@XmlElement(name = "Id")
private String id;
@XmlElement(name = "EventDate")
private String eventDate;
@XmlElement(name = "SendDate")
private String sendDate;
@XmlElement(name = "ActionCallInfo")
private String actionCallInfo;
@XmlElement(name = "ActivityRepCallInfo")
private String activityRepCallInfo;
@XmlElement(name = "AccountEPKId")
private String accountEPKId;
@XmlElement(name = "AccountCRMId")
private String accountCRMId;
@XmlElement(name = "CallId")
private String сallId;
@XmlElement(name = "CalledFromNum")
private String calledFromNum;
@XmlElement(name = "AppealName")
private String appealName;
@XmlElement(name = "CallbackPhone")
private String callbackPhone;
@XmlElement(name = "EndDate")
private String endDate;
@XmlElement(name = "Comment")
private String comment;
@XmlElement(name = "Result")
private String result;
@XmlElement(name = "CreatorFullName")
private String creatorFullName;
@XmlElement(name = "EmployeeId")
private String employeeId;
@XmlElement(name = "CRMCCQuestionInfo")
private String crmccQuestionInfo;
@XmlElement(name = "ServiceRequestInfo")
private String serviceRequestInfo;
@XmlElement(name = "ActionMeetingInfo")
private String actionMeetingInfo;
@Override
public String toString() {
return "BusinessOperationEvent{" +
"rqUID='" + rqUID + '\'' +
", rqTm='" + rqTm + '\'' +
", sPName='" + sPName + '\'' +
", systemId='" + systemId + '\'' +
", method='" + method + '\'' +
", businessProcess='" + businessProcess + '\'' +
", operation='" + operation + '\'' +
", step='" + step + '\'' +
", sourceModule='" + sourceModule + '\'' +
", id='" + id + '\'' +
", eventDate='" + eventDate + '\'' +
", sendDate='" + sendDate + '\'' +
", actionCallInfo='" + actionCallInfo + '\'' +
", activityRepCallInfo='" + activityRepCallInfo + '\'' +
", accountEPKId='" + accountEPKId + '\'' +
", accountCRMId='" + accountCRMId + '\'' +
", сallId='" + сallId + '\'' +
", calledFromNum='" + calledFromNum + '\'' +
", appealName='" + appealName + '\'' +
", callbackPhone='" + callbackPhone + '\'' +
", endDate='" + endDate + '\'' +
", comment='" + comment + '\'' +
", result='" + result + '\'' +
", creatorFullName='" + creatorFullName + '\'' +
", employeeId='" + employeeId + '\'' +
", crmccQuestionInfo='" + crmccQuestionInfo + '\'' +
", serviceRequestInfo='" + serviceRequestInfo + '\'' +
", actionMeetingInfo='" + actionMeetingInfo + '\'' +
'}';
}
}
我的应用程序的流程是用户可以选择食物,选择日期(从当前日期起7天),以及时间列表,然后点击提交。数据库将接收所有数据并保存到firebase中。
答案 0 :(得分:2)
我们可以使用Bundle
将数据从一个fragment
发送到另一个fragment
<强> SendingFragment 强>
RecievingFragment fragment = new RecievingFragment ();
Bundle args = new Bundle();
args.putString("Key", "Value");
fragment.setArguments(args);
getFragmentManager().beginTransaction().add(R.id.container, fragment).commit();
<强> RecievingFragment 强>
在新片段的onCreateView
中:
String value = getArguments().getString("YourKey");
答案 1 :(得分:0)
你可以通过传递活动来做到这一点,但是调用一个将在第二个片段上调用方法的方法,或者你可以通过扩展应用类来轻松使用全局变量,这将很容易,如何使用全局扩展Application类的变量