【发布时间】:2016-09-08 20:46:38
【问题描述】:
我是 android 新手,正在尝试使用
将包从 Activity 发送到 FragmentBundle 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;
}
在Bundle bundle = this.getArguments();获得null pointer exception
请帮我追踪这个异常
【问题讨论】: