更改视图中的片段上的按钮点击 [英] Changing view of a fragment on button clicks

查看:108
本文介绍了更改视图中的片段上的按钮点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android应用程序的工作。在我的应用我不得不改变一个片段上的按钮点击视图。以下是我的code:

I am working with an Android application. In my app I have to change the view of a fragment on button clicks. The following is my code:

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的观点()。我怎么能做到这一点的片段?

In activity we can change the view by using setContentView(). How can I do that in fragment?

推荐答案

我找到答案了我question.Actually非常愚蠢doupt。

I found answer for my question.Actually very stupid doupt.

edit.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                /**
                 * Edit button click will replace Settings screen to
                 * edit screen
                 **/

                theLayout = (LinearLayout)inflater.inflate(R.layout.edit_settings, container, false);


            }
        });

这篇关于更改视图中的片段上的按钮点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆