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

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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With