In my main.xml layout, I have an <FrameLayout>
element which is the fragment placeholder:
main.xml:
<FrameLayout
android:id="@+id/fragment_placeholder"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
I add Fragment programmatically to the above <FrameLayout>
by:
fragmentTransaction.add(R.id.fragment_placeholder, fragment, null);
I can then use the replace()
to change to other fragment:
fragmentTransaction.replace(R.id.fragment_placeholder, otherFragment, null);
At some point of my project, I need to get the current showing fragment, and disable everything on the view. I firstly successfully get the current showing fragment by :
Fragment currentFragment = fragmentManager.findFragmentById(R.id.fragment_placeholder);
Then, how can I disable the view of the fragment ? On the view, there could be buttons, is it possible to disable the whole view? If it is not possible, how can I add an overlay on the view?
I tried:
currentFragment.getView().setEnabled(false);
But, it does not work, I can still click on buttons on the view.