Fragment에서 Bundle을 이용한 데이터 전달에 관해서 잘 안되는 게 있어서 질문글을 올립니다.
먼저 지금 제가 하고 있는 것은 a라는 fragment에서 데이터를 b fragment로 전달하는 것입니다.
그래서 b fragment에서는 newInstance 메서드를 하나 만들었습니다. 이런식으루요.
public static bfragment newInstance(String param1, String param2) {
bfragment fragment = new bfragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
a fragment에서 버튼 클릭을 하면 newInstance 메서드가 실행됨과 동시에 startActivity로 해당 프래그먼트를 가진 액티비티로 넘어가게 했습니다.
bfragment.newInstance(item_name, item_type);
startActivity(new Intent(getActivity.getApplicationContext, bactivity.class));
이랬는데 bfragment에서는 getArgument = null이 됩니다. 즉 데이터 전달이 안되었다는 거죠.
뭐가 문제일까요??