0

I made android program, and it has a viewpager with three fragment. So, you can handle three screen with your finger and here comes problem. After i did something in a first page, then i want to refresh or update second fragment.

For example, once i input some text in a first page, then in a second page this text appear. If i input text again, then in a second page also textview has changed. Please give me some information to handle viewpager and fragment.

As i know, viewpager load page and next page. Then how can i update next page in viewpager?

user3064914
  • 921
  • 1
  • 7
  • 18
Moon Taejin
  • 351
  • 3
  • 9
  • 21
  • sorry i couldnt understand..! do you want to update the text in second fragment according to first fragment? is that what you want? – Kailash Dabhi Jan 16 '14 at 07:14
  • yes, when i do something in first page. then second page or third page have to be changed. but in viewpager, next page is not updated. – Moon Taejin Jan 16 '14 at 07:15

2 Answers2

0

I have more or less answered the same question here: Android: Get Fragment Reference from ViewPager/FragmentStatePagerAdapter

In short, you need to update some model data that the next page will read upon onResume(). This way the page will show the updated data.

Community
  • 1
  • 1
cYrixmorten
  • 7,110
  • 3
  • 25
  • 33
0

you should make the info static which you want to share in your first fragment and then use that static data in your second fragment.Actually im out of station so i just show you the demo code to get you on path:).Like this:---

 class FirstFragment extend Fragment{
 public static String text;

 /// then assign the text according to your events and you can access this in second   fragment
 }

class Second Fragment extends Fragment{
  onCreateView(....){
        TextView your_textview = (TextView)findViewById(R.id.your_textview);
        your_textview.setText(FirstFragment.text);
      }
}
Kailash Dabhi
  • 3,473
  • 1
  • 29
  • 47