Questions tagged [fragmentmanager]

FragmentManager is an interface for interacting with Fragment objects inside an Activity in Android. While the FragmentManager API was introduced in HONEYCOMB, a version of the API at is also available for use on older platforms through FragmentActivity. For more information about using fragments, read the Fragments developer guide.

700 questions
2
votes
1 answer

Refresh Fragment view in ViewPager

In my application I have 3 fragments in a viewPager. For the first fragment I would like to reload the view after a button press (basically call again the onCreateView()). To get this functionality I decided to use FragmentTransaction, detach(),…
2
votes
1 answer

EditText field gets an incorrect output

So, I have this testing app where I am trying to have two fragments communicate via MainActivity. After some research, I have managed to pass data from MainFragment to FragmentTwo. However, whenever I pass in string value from the MainFragment, I…
2
votes
2 answers

Using FragmentManager to always return to the same fragment

I am developing an application which contains NavigationDrawer with multiple tabs, which calls to different fragments. Let's say I have fragments A, B, C. On the creation of the activity the fragment container is populated with fragment A. I want…
2
votes
2 answers

NullPointerException on getSupportFragmentManager()

I am gettin NullPointerException on line: FragmentManager fragmentManager = ((ProductActivity)context).getSupportFragmentManager(); fragmentManager.beginTransaction().replace(R.id.frame_container, fragment).commit(); The context is returning null…
2
votes
1 answer

IllegalStateException: No activity FragmentManager.java

I was using Eclipse to compile the app, I used to get this error but not a lot. But since I've switch to android studio, I'm getting this crash a lot. Its crashing pretty much every device. I've tried doing everything but can't seem to fix this…
2
votes
2 answers

Back press fragments issue in android

I have four Fragments: A, B, C, D. Now I am moving from A --> B so my code will be from A to B getActivity().getSupportFragmentManager() .beginTransaction() .replace(R.id.content_frame, new B()) .addToBackStack("A") .commit(); Now…
2
votes
2 answers

Fragment - replace container, if id is not unique

I have a layout that has two views with the same id. If I want to find the view I just call parentView1.findViewById(R.id.content) or parentView2.findViewById(R.id.content) to get the correct view. If I want to replace a container with a fragment,…
prom85
  • 16,896
  • 17
  • 122
  • 242
2
votes
2 answers

When to use FragmentManager.isDestroyed()? To avoid IllegalStateException?

I have a listener in my Activity replace a Fragment after a network request is finished on another thread. So this listener is calling a line of code like this: getFragmentManager().beginTransaction().replace(R.id.container, fragment,…
pumpkinpie65
  • 960
  • 2
  • 14
  • 16
2
votes
0 answers

Get Target Fragment () returns null

I have done a lot of research on this issue that I am getting, but I am unable to solve this error. Over the Internet, folks are suggesting to use findFragmentBy ID or Tag, but both of them resulting in null Pointer Exception. This is the Code that…
Sankalps
  • 23
  • 4
2
votes
2 answers

Android: NullPointerException using findFragmentById() after ugrading support libraries

I just switched an old Android project from Eclipse to Android Studio and in that process I updated from the old support libraries version 19.0.1 to 22.2.0. After this I get some errors in my previously working code. I dowloaded all SDKs in between…
Krøllebølle
  • 2,878
  • 6
  • 54
  • 79
2
votes
0 answers

Android onNavigationDrawerItemSelected is causing setContentView to raise an exception

I am trying to create an activity with a navigation drawer. At first it had this onNavigationDrawerItemSelected method and it worked fine: @Override public void onNavigationDrawerItemSelected(final int position) { Fragment f =…
CodeMonkey
  • 11,196
  • 30
  • 112
  • 203
2
votes
1 answer

Showing and hiding fragments are not committed (don't occur) immediately when SwipeRefreshLayout is refreshing

So basically what I'm working on is very similar to Instagram application, where there're a number of tabs and users can switch to any tab without any delay no matter what there's anything going on, such as refreshing, reloading, and etc. It also…
Lee Han Kyeol
  • 2,371
  • 2
  • 29
  • 44
2
votes
0 answers

Loading Android Fragment on second time

There is a problem with loading view on second time. First time there is no problem, and my fragment is properly loading, but on second time there is i don't know default view or empty. Here is my essential code: @Override public View…
waclaw
  • 433
  • 1
  • 7
  • 18
2
votes
1 answer

How to remove fragment from fragment manager when activity is restored after being destroyed

I have an activity A which contains fragment F. A shows F by pushing it onto fragment manager's back stack. This fragment may show a dialog(more specifically, a DialogFragment) D, also by pushing it to the same fragment manager's back stack. I need…
Anton Cherkashyn
  • 5,719
  • 6
  • 43
  • 80
2
votes
2 answers

TextView setText not working

I am trying to setText to the textviews in the fragment which is contained in the activity. When I set text using the setText method I can see that the mText class variable of the textview is assigned that value. However, on the UI end I cannot see…