An invisible layout behind the fragment is getting clicked:
You need to make the root ViewGroup of VenueFragment clickable so it handles click events and they do not pass down (in the z-order sense) to the other Fragment.
You need to make the root ViewGroup of VenueFragment clickable so it handles click events and they do not pass down (in the z-order sense) to the other Fragment.
To solve this, if you are using android.app.DialogFragment, then use getFragmentManager(): mDateButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { FragmentManager fm = getActivity().getFragmentManager(); DatePickerFragment dialog = new DatePickerFragment(); dialog.show(fm, DIALOG_DATE); } }); to use getSupportFragmentManager(), must extend from: android.support.v4.app.DialogFragment. check your import: import android.support.v4.app.DialogFragment;
Starting from support library version 26.0.0 Beta 1 a new API is available in FragmentManager and Fragment classes: FragmentManager and Fragment have an isStateSaved() method to allow querying whether or not a transaction will be allowed without state loss. This is especially useful to check when handling an onClick() event before executing any transaction. From … Read more
It’s not called because this method has been added in API 23. If you run your application on a device with API 23 (marshmallow) then onAttach(Context) will be called. On all previous Android Versions onAttach(Activity) will be called. http://developer.android.com/reference/android/app/Fragment.html#onAttach(android.app.Activity) Support libraries fragment is platform independent. Hence it works on all API versions.
getFragmentManager() Return the FragmentManager for interacting with fragments associated with this activity. FragmentManager which is used to create transactions for adding, removing or replacing fragments. fragmentManager.beginTransaction(); Start a series of edit operations on the Fragments associated with this FragmentManager. The FragmentTransaction object which will be used. fragmentTransaction.replace(R.id.fragment_container, mFeedFragment); Replaces the current fragment with the mFeedFragment … Read more
Answering my own question: This exception is (eventually) thrown when you call FragmentTransaction.remove(null); and FragmentTransaction.commit(); EDIT: And also, like Twice Circled and shinyuX point out in the comment; when calling the show(null) or add(null), attach(null) and detach(null) methods, and probably also hide(null) After calling commit(), the transaction will be queued in the FragmentManager. As a … Read more
UPDATE 2021-06-14: At this point, ViewPager itself is all but deprecated. Technically, ViewPager is not deprecated, but the two concrete PagerAdapter implementations — FragmentPagerAdapter and FragmentStatePagerAdapter — are deprecated. Ideally, switch to something else, such as ViewPager2 or the pager composable in Accompanist. Replace: class MyViewPagerAdapter(manager: FragmentManager) : FragmentPagerAdapter(manager) with: class MyViewPagerAdapter(manager: FragmentManager) : FragmentPagerAdapter(manager, … Read more
You can directly call getParentFragmentManager() to get the fragment manager. Note that getFragmentManager() also works but has been marked as deprecated.