Restore Fragment Default Values Onswipe
there are to many threads talking about this but i tried everything and doens't seem to work. My Problem is kinda simple i have a viewpager with 5 fragments pages. Each of this fra
Solution 1:
well i figured it out.
Well as we "all" know viewpager creates 3 pages, and this pages will be set at NOT VISIBLE and VISIBLE. I googled around and found this:
@OverridepublicvoidsetUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser) {
Log.w("Visible1", "CurrentPage " + mCurrentPage);
} else {
Log.w("NOTVISIBLE1", "CurrentPage " + mCurrentPage);
if (edt != null) {
edt.setText("");
}
}
}
Well when i swipe and swipe back my values will be reseted, the "if" is because the view maybe its not created yet, this method is called before the onCreate() method. But it works, i don't know if you guys agree or have a better solution for this. I hope it will help someone.
Cheers
Post a Comment for "Restore Fragment Default Values Onswipe"