Like the button below the added fragment in the Relative layout, you can click

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

enter image description here

Image of the added fragment enter image description here

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.

+2
android android-layout
source share
2 answers

I know I'm late to answer here, but you need to set the main layout of your β€œEnter the price of the product” layout so that the clickable property is set to true , so that instead it absorbs clicks on it, transferring them to the main fragment.

+5
source share

For this situation, you should use two different Fragments with two different layouts. The problem may be with: fragmentTransaction.show(mMiscFragment); but I will need to see more code to know exactly what you are doing

0
source share

All Articles