fragmenttransaction

Can't get objectAnimator working with xFraction

荒凉一梦 提交于 2019-11-30 09:37:21
问题 I'm trying to animate a slide-in/slide-out animation between Fragments . I know there're tons of similiar question out there on StackOverflow , but believe me - I tried all of them and none is working. Following my code (basically taken from similiar questions): Custom Layout public class SlidingFrameLayout extends FrameLayout { public SlidingFrameLayout(Context context) { super(context); } public SlidingFrameLayout(Context context, AttributeSet attrs) { super(context, attrs); } public float

Android Fragment - move from one View to another?

岁酱吖の 提交于 2019-11-30 07:31:44
问题 Can i first add a Fragment to a View, then "detach" it, and then "re-attach" it to another View? In code, i want to: fragOne one = new fragOne(); getSupportFragmentManager().beginTransaction() .add(R.id.left, one, "tag").commit(); getSupportFragmentManager().beginTransaction() .detach(one).commit(); // or .remove(), or .addToBackStack(null).remove() getSupportFragmentManager().executePendingTransactions(); getSupportFragmentManager().beginTransaction() .add(R.id.right, one).commit(); But it

Fragment isAdded() returns false on an already added Fragment

£可爱£侵袭症+ 提交于 2019-11-30 07:07:14
问题 I have this neat function: private void addMapFragment(){ if(!mapFragment.isAdded()){ FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.add(R.id.mapContainer, mapFragment); ft.commit(); } } I'm calling addMapFragment() in my activity's onCreate() . I then have a callback from a webrequest that calls addMapMapFragment() . The isAdded() method doesn't look useful at all since I'm getting a crash saying "Fragment already added: MapFragment[...] " Any clue? 回答1:

An invisible layout behind the fragment is getting clicked:

≡放荡痞女 提交于 2019-11-30 00:57:54
问题 I have created several fragments and I add the first fragment the following way: mainFragment = (MainFragment) MainFragment.create(); getSupportFragmentManager().beginTransaction() .setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left, R.anim.slide_in_left, R.anim.slide_out_right) .add(R.id.content, mainFragment, MAIN_FRAGMENT_TAG) .commit(); The second fragment is added this way: getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.slide_in_right, R.anim

FragmentTransaction : replace and addToBackStack not working together?

匆匆过客 提交于 2019-11-30 00:49:36
I'm fairly new to Android development and now running in to weird behaviour. I have an empty FrameLayout to be the container of a fragment. If user press a button for the first time, generate new Fragment and put inside container. If user press a button later and there is existing fragment inside container, replace existing one with newly generated one. If user press back button, pop away the fragment inside container. Here is my code public void showFragment(View v) { FragmentA f = new FragmentA(); FragmentManager fm = getSupportFragmentManager(); String tag = f.getFragmentTag(); // instance

Can't get objectAnimator working with xFraction

大城市里の小女人 提交于 2019-11-29 16:38:08
I'm trying to animate a slide-in/slide-out animation between Fragments . I know there're tons of similiar question out there on StackOverflow , but believe me - I tried all of them and none is working. Following my code (basically taken from similiar questions): Custom Layout public class SlidingFrameLayout extends FrameLayout { public SlidingFrameLayout(Context context) { super(context); } public SlidingFrameLayout(Context context, AttributeSet attrs) { super(context, attrs); } public float getXFraction() { final int width = getWidth(); if (width != 0) return getX() / getWidth(); else return

AppCompat Action Bar library not displaying added fragments

坚强是说给别人听的谎言 提交于 2019-11-29 13:41:43
EDIT : If I extend FragmentActivity instead of ActionBarActivity my layout shows up again (without an ActionBar of course). The ActionBar works as intended on 4.x devices, but on my 2.3 device all I get is the ActionBar and a blank screen below it. The Fragment doesn't seem to be getting added to the Activity . themes.xml <style name="AppTheme" parent="AppBaseTheme"> <item name="actionBarStyle">@style/Widget.ActionBar</item> </style> themes-v11.xml <style name="AppTheme" parent="AppBaseTheme"> <item name="android:actionBarStyle">@style/Widget.ActionBar</item> </style> styles.xml <style name=

Android - Making translations and objectAnimator on the same XML file

我的梦境 提交于 2019-11-29 04:23:49
I've been trying to make a 3D Cube rotation effect while sliding from one fragment to another. First i was using a translate effect (on XML) calling with FragmentTransaction.setCustomAnimations(...) and then, when opening/closing the fragment, i was playing with the Camera classe to make the rotation. This was working FINE, but seems that I HAVE TOO (don't ask me why) use all of this animation using only XML file. After a long search i found out that i should use objectAnimator to make the rotation. Followed the Google sample and i manage to make the flip animation. Now i need to translate the

Android Fragment - move from one View to another?

ぃ、小莉子 提交于 2019-11-29 04:11:43
Can i first add a Fragment to a View, then "detach" it, and then "re-attach" it to another View? In code, i want to: fragOne one = new fragOne(); getSupportFragmentManager().beginTransaction() .add(R.id.left, one, "tag").commit(); getSupportFragmentManager().beginTransaction() .detach(one).commit(); // or .remove(), or .addToBackStack(null).remove() getSupportFragmentManager().executePendingTransactions(); getSupportFragmentManager().beginTransaction() .add(R.id.right, one).commit(); But it throws error: 04-05 13:28:03.492: E/AndroidRuntime(7195): java.lang.RuntimeException: Unable to start

Nested fragments transitioning incorrectly

倖福魔咒の 提交于 2019-11-29 03:08:59
Hello good programmers of stack overflow! I've spent a good week with this problem and am now very desperate for a solution. The scenario I'm using android.app.Fragment's not to be confused with the support fragments. I have 6 child fragments named: FragmentOne FragmentTwo FragmentThree FragmentA FragmentB FragmentC I have 2 parent fragments named: FragmentNumeric FragmentAlpha I have 1 activity named: MainActivity They behave in the following: Child fragments are fragments that only show a view, they do not show nor contain fragments. Parent fragments fill their entire view with a single