@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
et=(EditText)rootView.findViewById(R.id.et1);
String str=et.getText().toString();
Fragment frag=new Fragment();
Bundle bundle1=new Bundle();
bundle1.putString("name", str);
frag.setArguments(bundle1);
getFragmentManager().beginTransaction().add(R.id.container_body, frag).commit();
return inflater.inflate(R.layout.fragment_currentmovie, container, false);
}
}
它正在显示rootView无法解决,我需要添加编辑文本et字符串str,以便使用束我可以传递它到下一个片段
尝试添加膨胀器然后返回。
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_currentmovie, container, false);
et=(EditText)rootView.findViewById(R.id.et1);
String str=et.getText().toString();
Fragment frag=new Fragment();
Bundle bundle1=new Bundle();
bundle1.putString("name", str);
frag.setArguments(bundle1);
getFragmentManager().beginTransaction().add(R.id.container_body, frag).commit();
return rootView ;
}
}
你需要先充气:
View rootView = inflater.inflate(R.layout.fragment_currentmovie, container, false);
...
return rootview;