I have my MyActivity that contains three fragments: 1 ListFragment (listFragmentTest
) and 2 Fragments.
My listFragmentTest
contains a button. If the user click on this button it will be launched a new activity (activityTest
).
This activityTest
contains an EditText Field, where the user can enter a title.
After click on the Button "Save" (in the activityTest
) I want to send the String "title" to the listFragmentTest
and show the title in an EditText Field of my listFragmentTest
.
Here is the code from my activityTest for the button:
public void buttonSaveTitle(){
saveButtonTitleToFragment = (Button) findViewById(R.id.save_button_title_to_fragment);
saveButtonTitleToFragment.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText editTextTitle = (EditText) findViewById(R.id.edit_text_title_activity);
String title = editTextTitle.getText().toString();
//And here: Send the String to the listFragment
}
});
}
I'm new to android development and I tried it with intent and bundle, but without a solution.
EDIT:
I cannot use findFragmentById
. The ListFragment has no Id, because it's only a Tab. I've searched and find that I've to set the tag with FragmentTransaction.add
. But I don't know where I have to insert the FragmentTransaction.add
in my project.
Or is there another solution without using an id or tag?