Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Button below added fragment in Relative layout are clickable

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

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

enter image description here

Picture of added Fragment enter image description here

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 .

like image 721
Bora Avatar asked Dec 06 '25 06:12

Bora


1 Answers

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.

like image 135
Carl Anderson Avatar answered Dec 08 '25 15:12

Carl Anderson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!