From getSupportFragmentManager to getFragmentManager












0















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;









share|improve this question

























  • "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 Fragments and native Fragments?

    – 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 Fragments. 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 Fragments?

    – Mike M.
    Nov 25 '18 at 16:52
















0















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;









share|improve this question

























  • "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 Fragments and native Fragments?

    – 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 Fragments. 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 Fragments?

    – Mike M.
    Nov 25 '18 at 16:52














0












0








0








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;









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 your Fragment-related classes should be imported from the support library. Why are you mixing support Fragments and native Fragments?

    – 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 Fragments. 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 Fragments?

    – 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 Fragments and native Fragments?

    – 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 Fragments. 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 Fragments?

    – 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 Fragments and native Fragments?

– 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 Fragments and native Fragments?

– 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 Fragments. Is there some reason you're not?

– Mike M.
Nov 25 '18 at 16:49





My suggestion is to use only support Fragments. 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 Fragments?

– Mike M.
Nov 25 '18 at 16:52





Why is that preventing you from using support Fragments?

– Mike M.
Nov 25 '18 at 16:52












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
});


}
});














draft saved

draft discarded


















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
















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)