如何按钮下方的相对布局添加片段是可点击 [英] How Button below added fragment in Relative layout are clickable

查看:273
本文介绍了如何按钮下方的相对布局添加片段是可点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个RelativeLayout的动态地添加一个片段。在我相对布局有一些按钮
已经在那了 。
当添加布局片段,不显示的按钮,意味着隐藏的,但是点击
按钮的位置单击事件被调用。怎么样?

I am adding a fragment in a relativelayout dynamically. In my relative layout there are some buttons already there . When adding a fragment in layout ,buttons are not displayed , means hidden , but clicking on buttons position click event is called. How ?

为了解决这个问题,我只是启用和禁用的重视和片段的分离按钮

To solve this issue i am simply enable and disabling the button on attach and on detach of fragment

在code增加一个片段

The code for adding a fragment

private void showMiscOptions() {

    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager
            .beginTransaction();

    if (mMiscFragment != null && mMiscFragment.isAdded()) {

        fragmentTransaction.show(mMiscFragment);

    } else {

        fragmentTransaction.add(R.id.order_container, mMiscFragment);

    }
    fragmentTransaction.commit();
    mFragNamLabel.setText("Add Item");
}

我的观点是如何在没有按钮可见事件获取调用
请同时参阅图像

My point is how the event is getting called when there is no button visible please refer images also

片段添加图片

Picture of added Fragment

在我的片段布局添加和按钮是不可见的,但是点击这些红色
片段呼叫按钮的事件背后的区域。

When my fragment is added in layout , and buttons are not visible but clicking on those red areas of fragment calling the events of buttons behind that .

推荐答案

我知道我来不及回答这里,但你需要设置你的输入项目价格布局的主要布局有点击属性设置为真正,使其吸收点击了它,而不是将它们转移到底层的片段。

I know I'm late to answering here, but you need to set the main layout of your "Enter Item Price" layout to have the clickable property set to true, so that it absorbs clicks on it instead of transferring them to the underlying fragment.

这篇关于如何按钮下方的相对布局添加片段是可点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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