I have two fragment, one is Fragment X and Fragment y.. Fragment X is used for signup process using webservice. I want to pass(email,mobile) same value from Fragment X to Fragment Y.
Here my code:
Fragment x:
Signup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String sName = Name.getText().toString();
String sPhoneNo = Phone.getText().toString();
String sEmailId = EmailId.getText().toString();
// Instantiate Http Request Param Object
RequestParams params = new RequestParams();
if (Utility.isNotNull(sName) && Utility.isNotNull(sPhoneNo) && Utility.isNotNull(sEmailId) ) {
if (Utility.line2_validate(sName)) {
if (Utility.validate(sPhoneNo)) {
if (Utility.email_validate(sEmailId)) {
//Get value from this Fragment
FragmentY pf = new FragmentY ();
Bundle args = new Bundle();
args.putString("mobile", sPhoneNo);
args.putString("email",sEmailId);
pf.setArguments(args);
//Inflate the fragment
getFragmentManager().beginTransaction().add(R.id.passwordLayout, pf).commit();
// Put Http parameter username with value of Name Edit View control
params.put("name", sName);
// Put Http parameter email with value of Email Edit Value control
params.put("email", sEmailId);
// Put Http parameter mobile with value of Mobile Edit Value control
params.put("mobile", sPhoneNo);
// Invoke Signup RESTful Web Service with Http parameters
signUpWS(params);
//Toast.makeText(getActivity().getApplicationContext(), "Success", Toast.LENGTH_SHORT).show();
//((MainActivity) getActivity()).navigatetoPasswordActivity();
}
else {
EmailId.setError("Enter valid Email");
}
}
else {
Phone.setError("Enter valid Mobile");
}
}
else {
Name.setError("Enter valid Name");
}
}
else {
Toast.makeText(getActivity().getApplicationContext(), "Please fill the form, don't leave any field blank", Toast.LENGTH_SHORT).show();
}
}
});
Fragment Y:
// Retrive the value from fragment x
String strMobile = getArguments().getString("mobile");
String strEmail = getArguments().getString("email");
Please anyone help me..
Thanks in advance!