我是 android 新手,尝试使用 Activity 将包发送到 Fragment
Bundle args = new Bundle();
args.putString("name", "XXXXXXX");
FragmentTab1 fTab1 = new FragmentTab1();
fTab1.setArguments(args);
并在 FragmentTab1 onCreate 方法中如下:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Get the view from fragmenttab1.xml
View view = inflater.inflate(R.layout.fragmenttab1, container, false);
Bundle bundle = this.getArguments();
if (bundle != null) {
name = bundle.getString("name");
}
TextView nameView = (TextView) view.findViewById(R.id.dinesh);
nameView.setText(name);
return view;
}
到达null pointer exception
_ Bundle bundle = this.getArguments();
请帮我追踪这个异常