Im having PagerAdapter with 2 Fragments, after/while I enter data in first fragment1 editText1 i want the same data to be shown(update) in the next swiped fragment2 editText2
here is my Git-Hub...some one please help me with this ( https://github.com/raj5140/AAASwipe_Update )
I have tried tried many different ways, but it does not work, some1 please help me with this.
Ok so i just saw your code. I used robot's EventBus libaray for this purpose.
First i added
compile 'org.greenrobot:eventbus:3.0.0'
in build.gradle synced the project.
Then i made following changes in the fragments here is the code
Welcome_Slide1.java
public class Welcome_Slide1 extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View myFragmentView = inflater.inflate(R.layout.welcome_slide1, container, false);
EditText editText = (EditText) myFragmentView.findViewById(R.id.editText2);
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
EventBus.getDefault().post(s.toString());
}
@Override
public void afterTextChanged(Editable s) {
}
});
return myFragmentView;
}
}
Welcome_Slide2
public class Welcome_Slide2 extends Fragment {
EditText editText;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View myFragmentView = inflater.inflate(R.layout.welcome_slide2, container, false);
editText = (EditText) myFragmentView.findViewById(R.id.editText);
return myFragmentView;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
EventBus.getDefault().register(this);
}
@Override
public void onDetach() {
super.onDetach();
EventBus.getDefault().unregister(this);
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(String s){
editText.setText(s);
}
}
I hope this will help you. For more here is the link to library documentation