From getSupportFragmentManager to getFragmentManager
My app has two fragments with cardviews, if clicked on 1st fragment on a card, it will fetch the 2nd fragment and three buttons are above RecyclerView in each fragment.
Fragment was overlapped, so I give background color to stop (I know its a wrong process). And also used
container.removeAllViews();
In genymotion (4.4.4) the buttons are showing but in real device its showing the old buttons.
The problem is I am using two different FragmentManagers, one is getFragmentManager and the other is getSupportFragmentManager which is creating problem.
So I need to change the getSupportFragmentManager to getFragmentManager.
Can you help ???
AppCompatActivity appCompatActivity = (AppCompatActivity) view.getContext();
GroupAnswerSummary fragment = new GroupAnswerSummary();
//android.app.FragmentManager fragmentManager =((Activity)mContexts).getFragmentManager();
((Activity)mContexts).getFragmentManager().beginTransaction()
//appCompatActivity.getSupportFragmentManager().beginTransaction().replace(R.id.containerQ, fragment).addToBackStack(GroupAnswerSummary.class.getName()).commit();
XML is :
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context=".MainActivity"
android:id="@+id/containerQ">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="4dp"
android:scrollbars="vertical"
android:layout_marginTop="40dp"
/>
<Button
android:id="@+id/button_insert"
android:layout_width="wrap_content"
android:layout_height="37dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Ask"
android:textSize="12sp" />
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:progressDrawable="@color/colorPrimaryDark" />
<Button
android:id="@+id/button_i_asked"
android:layout_width="wrap_content"
android:layout_height="37dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="19dp"
android:text="I Asked"
android:textSize="12sp" />
<Button
android:id="@+id/button_temp"
android:layout_width="wrap_content"
android:layout_height="37dp"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="14dp"
android:text="temp"
android:textSize="12sp" />
</RelativeLayout>
Import :
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.gms.tasks.OnSuccessListener;
import java.util.ArrayList;
android xml
|
show 4 more comments
My app has two fragments with cardviews, if clicked on 1st fragment on a card, it will fetch the 2nd fragment and three buttons are above RecyclerView in each fragment.
Fragment was overlapped, so I give background color to stop (I know its a wrong process). And also used
container.removeAllViews();
In genymotion (4.4.4) the buttons are showing but in real device its showing the old buttons.
The problem is I am using two different FragmentManagers, one is getFragmentManager and the other is getSupportFragmentManager which is creating problem.
So I need to change the getSupportFragmentManager to getFragmentManager.
Can you help ???
AppCompatActivity appCompatActivity = (AppCompatActivity) view.getContext();
GroupAnswerSummary fragment = new GroupAnswerSummary();
//android.app.FragmentManager fragmentManager =((Activity)mContexts).getFragmentManager();
((Activity)mContexts).getFragmentManager().beginTransaction()
//appCompatActivity.getSupportFragmentManager().beginTransaction().replace(R.id.containerQ, fragment).addToBackStack(GroupAnswerSummary.class.getName()).commit();
XML is :
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context=".MainActivity"
android:id="@+id/containerQ">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="4dp"
android:scrollbars="vertical"
android:layout_marginTop="40dp"
/>
<Button
android:id="@+id/button_insert"
android:layout_width="wrap_content"
android:layout_height="37dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Ask"
android:textSize="12sp" />
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:progressDrawable="@color/colorPrimaryDark" />
<Button
android:id="@+id/button_i_asked"
android:layout_width="wrap_content"
android:layout_height="37dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="19dp"
android:text="I Asked"
android:textSize="12sp" />
<Button
android:id="@+id/button_temp"
android:layout_width="wrap_content"
android:layout_height="37dp"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="14dp"
android:text="temp"
android:textSize="12sp" />
</RelativeLayout>
Import :
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.gms.tasks.OnSuccessListener;
import java.util.ArrayList;
android xml
"The problem is I am using two different FragmentManagers" – Why? All of yourFragment
-related classes should be imported from the support library. Why are you mixing supportFragment
s and nativeFragment
s?
– Mike M.
Nov 25 '18 at 16:43
No, I don't want to use. Can you please suggest the proper method with code.
– Pranab Choudhury
Nov 25 '18 at 16:48
My suggestion is to use only supportFragment
s. Is there some reason you're not?
– Mike M.
Nov 25 '18 at 16:49
I am using it within RecyclerView.Adapter
– Pranab Choudhury
Nov 25 '18 at 16:51
Why is that preventing you from using supportFragment
s?
– Mike M.
Nov 25 '18 at 16:52
|
show 4 more comments
My app has two fragments with cardviews, if clicked on 1st fragment on a card, it will fetch the 2nd fragment and three buttons are above RecyclerView in each fragment.
Fragment was overlapped, so I give background color to stop (I know its a wrong process). And also used
container.removeAllViews();
In genymotion (4.4.4) the buttons are showing but in real device its showing the old buttons.
The problem is I am using two different FragmentManagers, one is getFragmentManager and the other is getSupportFragmentManager which is creating problem.
So I need to change the getSupportFragmentManager to getFragmentManager.
Can you help ???
AppCompatActivity appCompatActivity = (AppCompatActivity) view.getContext();
GroupAnswerSummary fragment = new GroupAnswerSummary();
//android.app.FragmentManager fragmentManager =((Activity)mContexts).getFragmentManager();
((Activity)mContexts).getFragmentManager().beginTransaction()
//appCompatActivity.getSupportFragmentManager().beginTransaction().replace(R.id.containerQ, fragment).addToBackStack(GroupAnswerSummary.class.getName()).commit();
XML is :
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context=".MainActivity"
android:id="@+id/containerQ">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="4dp"
android:scrollbars="vertical"
android:layout_marginTop="40dp"
/>
<Button
android:id="@+id/button_insert"
android:layout_width="wrap_content"
android:layout_height="37dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Ask"
android:textSize="12sp" />
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:progressDrawable="@color/colorPrimaryDark" />
<Button
android:id="@+id/button_i_asked"
android:layout_width="wrap_content"
android:layout_height="37dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="19dp"
android:text="I Asked"
android:textSize="12sp" />
<Button
android:id="@+id/button_temp"
android:layout_width="wrap_content"
android:layout_height="37dp"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="14dp"
android:text="temp"
android:textSize="12sp" />
</RelativeLayout>
Import :
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.gms.tasks.OnSuccessListener;
import java.util.ArrayList;
android xml
My app has two fragments with cardviews, if clicked on 1st fragment on a card, it will fetch the 2nd fragment and three buttons are above RecyclerView in each fragment.
Fragment was overlapped, so I give background color to stop (I know its a wrong process). And also used
container.removeAllViews();
In genymotion (4.4.4) the buttons are showing but in real device its showing the old buttons.
The problem is I am using two different FragmentManagers, one is getFragmentManager and the other is getSupportFragmentManager which is creating problem.
So I need to change the getSupportFragmentManager to getFragmentManager.
Can you help ???
AppCompatActivity appCompatActivity = (AppCompatActivity) view.getContext();
GroupAnswerSummary fragment = new GroupAnswerSummary();
//android.app.FragmentManager fragmentManager =((Activity)mContexts).getFragmentManager();
((Activity)mContexts).getFragmentManager().beginTransaction()
//appCompatActivity.getSupportFragmentManager().beginTransaction().replace(R.id.containerQ, fragment).addToBackStack(GroupAnswerSummary.class.getName()).commit();
XML is :
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context=".MainActivity"
android:id="@+id/containerQ">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="4dp"
android:scrollbars="vertical"
android:layout_marginTop="40dp"
/>
<Button
android:id="@+id/button_insert"
android:layout_width="wrap_content"
android:layout_height="37dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Ask"
android:textSize="12sp" />
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:progressDrawable="@color/colorPrimaryDark" />
<Button
android:id="@+id/button_i_asked"
android:layout_width="wrap_content"
android:layout_height="37dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="19dp"
android:text="I Asked"
android:textSize="12sp" />
<Button
android:id="@+id/button_temp"
android:layout_width="wrap_content"
android:layout_height="37dp"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="14dp"
android:text="temp"
android:textSize="12sp" />
</RelativeLayout>
Import :
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.gms.tasks.OnSuccessListener;
import java.util.ArrayList;
android xml
android xml
edited Nov 25 '18 at 17:23
hsm59
1,0221116
1,0221116
asked Nov 25 '18 at 16:41
Pranab ChoudhuryPranab Choudhury
13
13
"The problem is I am using two different FragmentManagers" – Why? All of yourFragment
-related classes should be imported from the support library. Why are you mixing supportFragment
s and nativeFragment
s?
– Mike M.
Nov 25 '18 at 16:43
No, I don't want to use. Can you please suggest the proper method with code.
– Pranab Choudhury
Nov 25 '18 at 16:48
My suggestion is to use only supportFragment
s. Is there some reason you're not?
– Mike M.
Nov 25 '18 at 16:49
I am using it within RecyclerView.Adapter
– Pranab Choudhury
Nov 25 '18 at 16:51
Why is that preventing you from using supportFragment
s?
– Mike M.
Nov 25 '18 at 16:52
|
show 4 more comments
"The problem is I am using two different FragmentManagers" – Why? All of yourFragment
-related classes should be imported from the support library. Why are you mixing supportFragment
s and nativeFragment
s?
– Mike M.
Nov 25 '18 at 16:43
No, I don't want to use. Can you please suggest the proper method with code.
– Pranab Choudhury
Nov 25 '18 at 16:48
My suggestion is to use only supportFragment
s. Is there some reason you're not?
– Mike M.
Nov 25 '18 at 16:49
I am using it within RecyclerView.Adapter
– Pranab Choudhury
Nov 25 '18 at 16:51
Why is that preventing you from using supportFragment
s?
– Mike M.
Nov 25 '18 at 16:52
"The problem is I am using two different FragmentManagers" – Why? All of your
Fragment
-related classes should be imported from the support library. Why are you mixing support Fragment
s and native Fragment
s?– Mike M.
Nov 25 '18 at 16:43
"The problem is I am using two different FragmentManagers" – Why? All of your
Fragment
-related classes should be imported from the support library. Why are you mixing support Fragment
s and native Fragment
s?– Mike M.
Nov 25 '18 at 16:43
No, I don't want to use. Can you please suggest the proper method with code.
– Pranab Choudhury
Nov 25 '18 at 16:48
No, I don't want to use. Can you please suggest the proper method with code.
– Pranab Choudhury
Nov 25 '18 at 16:48
My suggestion is to use only support
Fragment
s. Is there some reason you're not?– Mike M.
Nov 25 '18 at 16:49
My suggestion is to use only support
Fragment
s. Is there some reason you're not?– Mike M.
Nov 25 '18 at 16:49
I am using it within RecyclerView.Adapter
– Pranab Choudhury
Nov 25 '18 at 16:51
I am using it within RecyclerView.Adapter
– Pranab Choudhury
Nov 25 '18 at 16:51
Why is that preventing you from using support
Fragment
s?– Mike M.
Nov 25 '18 at 16:52
Why is that preventing you from using support
Fragment
s?– Mike M.
Nov 25 '18 at 16:52
|
show 4 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53469638%2ffrom-getsupportfragmentmanager-to-getfragmentmanager%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53469638%2ffrom-getsupportfragmentmanager-to-getfragmentmanager%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
"The problem is I am using two different FragmentManagers" – Why? All of your
Fragment
-related classes should be imported from the support library. Why are you mixing supportFragment
s and nativeFragment
s?– Mike M.
Nov 25 '18 at 16:43
No, I don't want to use. Can you please suggest the proper method with code.
– Pranab Choudhury
Nov 25 '18 at 16:48
My suggestion is to use only support
Fragment
s. Is there some reason you're not?– Mike M.
Nov 25 '18 at 16:49
I am using it within RecyclerView.Adapter
– Pranab Choudhury
Nov 25 '18 at 16:51
Why is that preventing you from using support
Fragment
s?– Mike M.
Nov 25 '18 at 16:52