I have a Fragment
FR1
that contains several Nested
Fragments
; FRa
, FRb
, FRc
. These Nested
Fragments
are changed by pressing Buttons
on FR1
's layout. Each of the Nested
Fragments
have several input fields within them; which include things like EditTexts
, NumberPickers
, and Spinners
. When my user goes through and fills in all the values for the Nested
Fragments
, FR1
(the parent fragment) has a submit button.
How can I then, retrieve my values from my Nested
Fragments
and bring them into FR1
.
- All
Views
are declared and programmatically handled within eachNested
Fragment
. - The parent
Fragment
,FR1
handles the transaction of theNested
Fragments
.
I hope this question is clear enough and I am not sure if code is necessary to post but if someone feels otherwise I can do so.
EDIT 1:
Here is how I add my Nested
Fragments
:
tempRangeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getChildFragmentManager().beginTransaction()
.add(R.id.settings_fragment_tertiary_nest, tempFrag)
.commit();
}
});
scheduleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getChildFragmentManager().beginTransaction()
.add(R.id.settings_fragment_tertiary_nest, scheduleFrag)
.commit();
}
});
alertsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getChildFragmentManager().beginTransaction()
.add(R.id.settings_fragment_tertiary_nest, alertsFrag)
.commit();
}
});
submitProfile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
constructNewProfile();
}
});
where my constructNewProfile()
method needs the values from my Nested
Fragments
.
public Fragment tempFrag = fragment_profile_settings_temperature
.newInstance();
public Fragment scheduleFrag= fragment_profile_settings_schedules
.newInstance();
public Fragment alertsFrag = fragment_profile_settings_alerts
.newInstance();
The above refers to the fields of the parent fragment; and how they are initially instantiated.