我正在使用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()
改变视图。我该如何做到这一点?
http://developer.android.com/reference/android/app/Fragment.html#getView()是指该链接 – Thiru 2012-08-07 10:55:34