I am trying to create a memeApp, I created two fragments:
- The first fragment has two
EditText
fields, where the user writes something and a button; - The second fragment has a picture, with two
EditText
fields, where one is top positioned in the picture, and the second is at bottom.
Fragment class A
public class topFragment extends Fragment {
private static EditText topText;
private static EditText botText;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.top_sectionfragment, container, false);
topText = (EditText) view.findViewById(R.id.topText);
botText = (EditText) view.findViewById(R.id.botText);
final Button buttonChange = (Button)
view.findViewById(R.id.buttonChange);
buttonChange.setOnClickListener(
new View.OnClickListener() {
public void onClick(View v) {
buttonClicked(v);
}
}
);
return view;
}
public void buttonClicked(View view) {
}
}
Fragment class B
public class bottomfragmentphoto extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.botfragment,container,false);
return view;
}
}
I want to know, how and what can I do, when I write something in EditText
from fragment A, to send the data to Fragment B? And all of this I want to do with mainActivity
.