【发布时间】:2012-08-07 10:50:03
【问题描述】:
我正在使用 Android 应用程序。在我的应用程序中,我必须更改按钮单击片段的视图。以下是我的代码:
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;
}
在活动中,我们可以使用setContentView() 更改视图。我怎样才能在片段中做到这一点?
【问题讨论】:
标签: android android-layout android-fragments