我想通过点击按钮来改变一个fragment视图
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
if (container == null) {
return null;
}
LinearLayout theLayout = (LinearLayout)inflater.inflate(R.layout.settings, container, false);
Button edit = (Button) theLayout.findViewById(R.id.btn_edit);
edit.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Here I want to change the view.[xml file]
}
});
return theLayout;
}
在 activity 中可以使用setContentView()
改变视图
如何在 fragment 中实现呢?