I add a fragment to relativelayout dynamically. In my relative layout there are several buttons already here. When you add a fragment to the layout, the buttons are not displayed, it means hidden, but the click triggers the button click event. How?
To solve this problem, I just turn on and off the button on the attach and detach fragment
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 fired when there is no button visible please refer to the images

Image of the added fragment 
When my fragment is added to the layout, and the buttons are not visible, but they click on the red areas of the fragment that trigger the button events for this.
android android-layout
Bora
source share