fragmenttransaction

Replacing fragments have wrong elevation value

*爱你&永不变心* 提交于 2019-12-05 11:08:38
问题 Hello again stack overflowians. I have another fragment question. (I'm using android.app.Fragment not Support Fragments) I'm trying to replace a fragment. But this isn't as simple as using: fragmentTransaction .replace(containerId, newFragment) .addToBackStack("unique tag") .commit() Why not? Good question friends, its because my newFragment has a transition animation. Where is the animation defined? Another great question, its defined in the fragments onCreateAnimator() Why is it defined

How to add a fragment to a layout of a DialogFragment?

最后都变了- 提交于 2019-12-05 09:44:10
I am having a custom DialogFragment which contains a layout, some UI elements, and a Fragment holder layout. What I need to do is inflate a Content fragment into the holder layout and provide a navigation inside that. On clicking a button inside the added fragment the view will navigate to another view. The fragment will be replaced by another one in the same holder i.e. the contentFragment1 will show some data and on clicking a preview button there will replace contentFragment1 with contentFragment2 . I read somewhere that you cannot replace a fragment hardcoded to the xml with another one.

Android: Getting white screen with fragment transaction

守給你的承諾、 提交于 2019-12-05 08:32:54
I am making a news app where I have a fragment that holds all the news in a list and another fragment that have videos list. When you touch a new it will call a method from the activity named openNewsCont that will replace the current fragment with another one. The proble I am having is when I call that method I get a blank screen, I have looked many other codes but I couldn't find the solution for my problem. Here is the method I call from the MainActivity.java public void openNewsCont(String text) { android.support.v4.app.FragmentManager fm = getSupportFragmentManager(); android.support.v4

Where Fragment save its State when FragmentTransaction.Replace?

痴心易碎 提交于 2019-12-05 06:20:56
问题 Backgroud: i have a menu on the left, and different scrollable contents on the right. i wanted to save the scrolled position. But i failed. Then ... I have set up a very simple project to test it. In words, i have a menu on the left, and different contents all holding an <EditText> on the right. (of the same class though, they are of different instances) In codes, (very simple) content.xml <EditText xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text" android

NullPointerException : FragmentManager.beginTransaction()

旧时模样 提交于 2019-12-04 18:24:53
问题 I'm getting this error while trying to launch a Fragment from a first Fragment : java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.FragmentTransaction android.app.FragmentManager.beginTransaction()' on a null object reference Here's the method where I'm getting the error : @Override public void onClick(View v) { Fragment fragment = new PropertyFragment(); if (fragment != null) { FragmentManager fragmentManager = fragment.getFragmentManager(); FragmentTransaction

FragmentTransaction&Activity的状态

懵懂的女人 提交于 2019-12-04 18:18:30
个人翻译的国外大牛博客 原文链接 自从Android Honeycomb发布以来,下面的异常信息和trace已经在StackOverflow提出了很多了: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1341) at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1352) at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:595) at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:574) 这篇博文会解释这个异常信息为什么会产生,什么时候会被抛出。并且通过提供几个建议确保你的App再也不会因此而挂掉。 为什么会产生这个异常 当Activity状态(state)已经被保存之后

Android FragmentTransaction.addToBackStack confusion

十年热恋 提交于 2019-12-04 17:24:49
问题 I was studying Fragments and got little confused on differentiating FragmentTransaction.replace(id, fragment, tag) and FragmentTransaction.addToBackStack(tag) calls. Lets say that my current fragment is FragmentA and then I loaded FragmentB . I want that in future, when I need to load FragmentA , I don't have to reload it. Just load the old one in old state. I used the following code segment: public void loadFragment(Fragment fragmentB, String tag) { FragmentManager fm =

FragmentTransaction not doing anything

末鹿安然 提交于 2019-12-04 02:41:35
I am learning fragments and below given is my first fragment program. A simple project where I have 2 screens. When I click the next button of first screen, second button needs to be shown. I am targeting Android 2.1 and above and using compatibility package AppMainFragmentActivity.java public class AppMainFragmentActivity extends FragmentActivity { @Override protected void onCreate(Bundle arg0) { super.onCreate(arg0); setContentView(R.layout.app_main_layout); } } app_main_layout.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

Is it OK to addToBackStack and replace in a fragment transaction?

青春壹個敷衍的年華 提交于 2019-12-04 00:23:01
Any thoughts on the following code? In my testing I've found the replaced fragment isn't destroyed and the instance is still around when popping the back stack. Just looking to verify that this is a valid way to use fragment transactions. getSupportFragmentManager().beginTransaction().addToBackStack(null).replace(frame, fragmentB).commit(); My reason for using replace is that it causes the replaced fragment to run it's exit animation. You can refer to the android designer guide for fragment transaction: http://developer.android.com/guide/components/fragments.html Specificly the snippet below:

Where Fragment save its State when FragmentTransaction.Replace?

余生长醉 提交于 2019-12-03 21:40:25
Backgroud: i have a menu on the left, and different scrollable contents on the right. i wanted to save the scrolled position. But i failed. Then ... I have set up a very simple project to test it. In words, i have a menu on the left, and different contents all holding an <EditText> on the right. (of the same class though, they are of different instances) In codes, (very simple) content.xml <EditText xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Please save my text ..." />