Communication between Fragments in ViewPager

前端 未结 4 1070
天命终不由人
天命终不由人 2020-12-01 06:57

I\'m trying to do this: http://android-er.blogspot.com/2012/06/communication-between-fragments-in.html Except that I\'m using a FragmentStatePagerAdapter

I have an

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-01 07:35

    FragmentB is not even created until you switch to it so fragmentB.updateText(textPassToB); gives you NullPointerException.

    You will need to store the text from the EditText in your activity and later when (if) the FragmentB is created you will need to read value from it.

提交回复
热议问题