fragmentmanager

java.lang.IllegalStateException(Can not perform this action after onSaveInstanceState)

隐身守侯 提交于 2019-12-21 20:42:18
问题 I am getting this error with following message in different scenario: Activity has been destroyed and Can not perform this action after onSaveInstanceState I am writing an app where Two Activity interacting with each Other. Activity-A launch Activity-B using Intent. This Activity-B class have two fragment children. Fragment-A use public method of activity to launch another Fragment-B . public void beginTransaction(ID id, Bundle bundle) { Fragment fragment = getFragmentItem(id); // In case

How to add/remove Fragment on Button click?

为君一笑 提交于 2019-12-21 04:34:26
问题 At present I have got a "RELATIVE_LAYOUT" container which I am using for adding my fragment. I am using OnClickListener on a button to load the fragment XML layout into the RelativeLayout container. What I want to achieve is that when I press the button once, the fragment should load...and when I press it again the fragment should be removed. I've already tried using integer to identify if fragment is loaded, but failed. Any help Appreciated... CODE: public class MainActivity extends Activity

Using Google Maps inside a Fragment in Android

强颜欢笑 提交于 2019-12-19 11:32:11
问题 I am trying to load Google Maps inside fragment ,and I keep getting the same error regardless of what solution I am trying to implement. I have already gone though all of the similar(if not the same) questions and have tried to do what the first few best answers have suggested but sadly without luck. So I really would appreciate it if you could help me out: My MainActivity.java is as follows: package com.nzf.nzf.nzfmap; import android.support.v4.app.Fragment; import android.os.Bundle; import

Fragment with ViewPager inside Fragment and FragmentStatePagerAdapter results in Exception (with complete example)

两盒软妹~` 提交于 2019-12-19 05:38:25
问题 I have a simple Fragment with a ViewPager. I'm using the up to date support library, v4 rev18! If I show the sub fragment the first time, everything works fine, if I go back and show it again, the app crashes with the following exception: I have a complete example which shows, WHEN the following exception is occuring: java.lang.NullPointerException at android.support.v4.app.FragmentManagerImpl.getFragment(FragmentManager.java:569) at android.support.v4.app.FragmentStatePagerAdapter

Fragment with ViewPager inside Fragment and FragmentStatePagerAdapter results in Exception (with complete example)

天涯浪子 提交于 2019-12-19 05:38:09
问题 I have a simple Fragment with a ViewPager. I'm using the up to date support library, v4 rev18! If I show the sub fragment the first time, everything works fine, if I go back and show it again, the app crashes with the following exception: I have a complete example which shows, WHEN the following exception is occuring: java.lang.NullPointerException at android.support.v4.app.FragmentManagerImpl.getFragment(FragmentManager.java:569) at android.support.v4.app.FragmentStatePagerAdapter

FragmentManager popBackStack doesn't remove fragment

痴心易碎 提交于 2019-12-18 11:50:03
问题 I'm implementing menu navigation using Fragments. So I begin with Home, and then users can navigate to diferent sections and details of each section. When a user changes section, then I call pop on the fragmentmanager backstack until I reach Home, and then load the new section. This is all working as expected. But I'm getting this problem: load a section that calls setHasOptionsMenu(true) on onResume() loads another section (old section it's suposed to get out of the stack). I see it OK. No

How can I implement FragmentManager and FragmentTransaction to replace just a single fragment?

二次信任 提交于 2019-12-18 06:18:05
问题 I have an activity with 3 fragments; a header; a body; a footer (same point as in HTML). The bodyfragment contains three buttons which each should replace the middle fragment (body; itself) with another one, but I can't figure out how to work FragmentManager and FragmentTransition in here. I can't seem to find any coherency in other peoples questions on here with regards to the way others implement their fragments. It seems everyone has their own methods, or just doesn't include the full code

Android FragmentManager BackStackRecord.run throwing NullPointerException

僤鯓⒐⒋嵵緔 提交于 2019-12-17 05:01:33
问题 I sometimes get the following exception when working with Fragments: FATAL EXCEPTION: main java.lang.NullPointerException at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:591) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416) at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:420) at android.os.Handler.handleCallback(Handler.java:615) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper

Android FragmentManager BackStackRecord.run throwing NullPointerException

天涯浪子 提交于 2019-12-17 05:00:38
问题 I sometimes get the following exception when working with Fragments: FATAL EXCEPTION: main java.lang.NullPointerException at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:591) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416) at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:420) at android.os.Handler.handleCallback(Handler.java:615) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper

How can I access getSupportFragmentManager() in a fragment?

人盡茶涼 提交于 2019-12-17 03:52:05
问题 I have a FragmentActivity and I want to use a map fragment within it. I'm having a problem getting the support fragment manager to access it. if (googleMap == null) { googleMap = ((SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map1)).getMap(); // check if map is created successfully or not if (googleMap == null) { Toast.makeText(getApplicationContext(), "Sorry! unable to create maps", Toast.LENGTH_SHORT) .show(); } } // create marker MarkerOptions marker = new