Fragment over another fragment issue
Set clickable
property on the second fragment's view to true. The view will catch the event so that it will not be passed to the main fragment. So if the second fragment's view is a layout, this would be the code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true" />
Fragment overlapping each other...and previous fragment is clicking
You're using fragmentTransaction.add()
, which won't remove the previous Fragment - use fragmentTransaction.replace()
if you want the other Fragment's view to be removed.
Note FragmentManager
automatically restores any previously added Fragments when your Activity is recreated (i.e., when savedInstanceState != null
). Therefore you'll want to ensure that you only add your initial Fragment once - when the savedInstanceState
is null.
if (savedInstanceState == null) {
loadFragment(new FragmentRegLogSkip(), FragmentRegLogSkip.FRAGMENT_KEY);
}
Adding a fragment on top of another fragment onClickListener issue
You can just add the following attribute to the XML root layout of the fragment that agoes on top-
android:clickable="true"
This will ensure that touch events will not propagate further than the top layer.
Fragment overlapping one on another in android
Your second fragment's parent layout must have a background.
PlayQuizSubjectWise XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFF" //Here
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
Invoking a fragment from another fragment and then replacing its layout
To get fragmentManger in fragment use
getActivity().getSupportFragmentManager()
As mentioned You should use R.id.flContent
as your frame layout host so use
fragmentTransaction.replace(R.id.flContent, f1);
instead of
fragmentTransaction.replace(R.id.tableLayout1, f1);
Related Topics
Start Activity Inside Onreceive Broadcastreceiver
Get List of Installed Android Applications
Cardview Layout_Width="Match_Parent" Does Not Match Parent Recyclerview Width
How to Change the Fontsize in an Android Webview
Intent to Launch the Clock Application on Android
Open Soft Keyboard Programmatically
Android - Get Time of Chronometer Widget
Android Material: Status Bar Color Won't Change
How to Draw a Route, Along an Existing Road, Between Two Points
Notificationcompat with API 26
Error Message:This Android Sdk Requires Android Developer Toolkit Version 22.6.1 or Above
How to Set Android_Sdk_Home Environment Variable
Error :: Duplicate Files During Packaging of APK
How to Get Response as String Using Retrofit Without Using Gson or Any Other Library in Android
Android: Autocompletetextview Show Suggestions When No Text Entered