Fragment向ChildFragment传值
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                Fragment向ChildFragment传值
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                
                            
                            
                            Fragment中:mTitle.add("A");mFragment.add(new AFragment("befollowId"));//將TabLayout和ViewPager聯系起來mTabLayout.setupWithViewPager(mViewPager);子Fragment中:@SuppressLint("ValidFragment")public class AFragment {private String befollowId;@SuppressLint("ValidFragment")public AFragment(String befollowId) {this.befollowId = befollowId;}public AFragment() {// Required empty public constructor}} 
                        
                        
                        將 s1從本Fragment傳值到AFragment中 ? (AFragment為Fragment的子Fragment) ? ??
1、new ?AFragment (“ befollowId?”) ;
2、AFragment用 ? ? ?@SuppressLint("ValidFragment") ? ? 修飾
3、子Fragment中構建一個有參構造方法 ?并且該方法用=以下注解修飾
注意:這里的無參構造方法不可以刪除 ? 否則會報錯
private String befollowId;@SuppressLint("ValidFragment") public AFragment(String befollowId) {this.befollowId = befollowId; }public AFragment() {// Required empty public constructor }總結
以上是生活随笔為你收集整理的Fragment向ChildFragment传值的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: Android怎么导入Moudle
 - 下一篇: Base64加密和Md5加密用户名