-2

I have a fragment (we can call fragment A) and I am inflating another view on top of fragment A (we will call that view B), but the buttons that are part of fragment A are visible in view B. In order to display view B I do:

LayoutInflater inflater = (LayoutInflater)getActivity().getSystemService
                (Context.LAYOUT_INFLATER_SERVICE);

        inflater.inflate(R.layout.coupon_input, (ViewGroup) getActivity().findViewById(R.id.rl_payment));

I'm wondering why the buttons that are part of fragment A are visible when I place view B on top of it? I can also click the buttons in fragment A through view B. How can I hide all of the views in Fragment A when I inflate view B over it?

BlackHatSamurai
  • 23,275
  • 22
  • 95
  • 156
  • try adding a background color and clickable property in root layout of your `coupon_input`..like: `android:background="@android:color/white" android:clickable="true"` – rafsanahmad007 Apr 16 '17 at 06:44
  • @rafsanahmad007 I set a background for my `coupon_input`. That is what is odd, is that the buttons from the `rl_payment` show through the background and I can click them. I want them hidden. – BlackHatSamurai Apr 16 '17 at 06:53
  • the second argument is the parent layout where your new layout will be added....if you want to override the parent layout completely set the height width to match parent..see [this](http://stackoverflow.com/questions/2335813/how-to-inflate-one-view-with-a-layout)\ – rafsanahmad007 Apr 16 '17 at 07:14

2 Answers2

0

you can set background color for Fragment B and set clickable to true for parent Layout of Fragment B

Sajad Garshasbi
  • 508
  • 1
  • 9
  • 23
-1

You should be able to manipulate view objects by setting their visibilities.

view.setVisibility(View.VISIBLE;

view.setVisibility(View.INVISIBLE);

view.setVisibility(View.GONE);

Kia
  • 124
  • 1
  • 1
  • 10