본문으로 바로가기
728x90

Android Studio가 2.3으로 업데이트 되면서 Fragment가 Constructor를 사용하여 데이터를 전달 받을수 있게 되었습니다.



1
2
3
4
5
6
7
8
9
10
11
public class NowFragment extends Fragment {
    Context mContext;
    String userId;
 
    public NowFragment (Context mContext, String userId) {
        this.mContext = mContext;
        this.userId = userId;
    }
}
 
new NowFragment(mContext, userId);
cs



하지만

APP을 release할 경우에는 기존에 Bundle을 이용해서 전달 받던 방식을 사용해야합니다. (오류가 발생합니다.)



728x90