fragmentmanager

android.support.v4.app.FragmentManager OR android.app.FragmentManager?

ε祈祈猫儿з 提交于 2019-12-03 07:05:29
I'm learning Android development. I get stuck at something that should be very easy. Im creating an App with one Activity, 2 fragments and 1 interface. android:minSdkVersion="11" android:targetSdkVersion="19 So in the main activity Im trying to create a reference to Fragment B using the manager. I get stuck here, because Eclispse is telling me to change some things (see below): My intension:` @Override public void respond(int i) { // TODO Auto-generated method stub FragmentManager manager =getFragmentManager(); FragmentB f2= (FragmentB) manager.findFragmentById(R.id.fragment2); }` If I do it

Android: master/detail flow (dual-pane) using 1 activity

拜拜、爱过 提交于 2019-12-03 07:03:07
As reported by the Android guide , dual-pane can be achieved in two ways: Multiple fragments, one activity Multiple fragments, multiple activities I am using the first case (the Android guide only explains the second case). This is what happens on 7" tablets : rotating from landscape to portrait : only the single-pane fragment gets recreated rotating from portrait to landscape : all 3 fragments (single-pane, dual-pane-master, dual-pane-detail) get recreated Question: why is the single-pane fragment (which I create programmatically, but using a FrameLayout defined in the layout as the container

java.lang.IllegalArgumentException: No view found for id 0x7f0904b3 (com.my.app:id/viewpagers) for fragment MyFavoriteFragment

这一生的挚爱 提交于 2019-12-02 19:04:34
问题 I am using BottomNavigation with fragments and in one of my bottom fragment I have added fragment inside fragment and used tablayout, Everything is working fine but sometimes app got crash gives follwing error.. java.lang.IllegalArgumentException: No view found for id 0x7f0904b3 (com.my.app:id/viewpagers) for fragment MyFavoriteFragment This is my bottom navigation Now in fourth fragment I have tablayout with viewpager, following is my code can anyone help me with this Parent Fragment public

Is there a way to listen to FragmentTransactions of a FragmentManager?

徘徊边缘 提交于 2019-12-02 13:37:08
I have an app with several Fragments which interact to each other. Sometimes I have to add a Fragment , sometimes I replace it. Is there a way to listen to FragmentTransactions completed, so I can keep track of every time a Fragment is added/shown/replaced? I've tried fragmentManager.addOnBackStackChangedListener() but unsuccessfully. I thought of doing something on the onResume() of all of them, but if the app goes to background and foreground I should not do anything to my UI. Only when I interact between them. Any help/strategy is appreciated. EDIT: The reason is that I have an overlay that

Cannot resolve for method show(android.app.FragmentManager, java.lang.String)

僤鯓⒐⒋嵵緔 提交于 2019-12-01 20:44:39
I've on API 23.Using RadialTimePickerDialogFragment that uses v4 The parent activity is based on Activity (we don't need Why am I getting Cannot resolve for method show(android.app.FragmentManager, java.lang.String) import com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment; import android.support.v4.app.DialogFragment; import com.gtfp.workingmemory.BuildConfig; import com.gtfp.workingmemory.R; import com.gtfp.workingmemory.colorPicker.colorPickerActivity; import com.gtfp.workingmemory.colorPicker.colorPickerView; import com.gtfp.workingmemory.frmwrk.frmwrkActivity;

Android using both getFragmentManager and getSupportFragmentManager causes overlapping

冷暖自知 提交于 2019-12-01 14:32:34
I have something like this inside my activity: @Override public void onNavigationDrawerItemSelected(int position) { Fragment fragment = null; switch (position+1) { case 1: { fragment = new Fragment_Login(); FragmentManager frgManager = getFragmentManager(); frgManager.beginTransaction().replace(R.id.container, fragment) .commit(); break; } case 2: { SwipeRefreshListFragment swipeFragment = new Fragment_List_Of_Assessments(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.container, swipeFragment) .commit(); break; } case 3: { fragment

Using Google Maps inside a Fragment in Android

女生的网名这么多〃 提交于 2019-12-01 12:44:26
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 android.support.v4.app.*; import android.support.v4.view.ViewPager; import android.util.Log; import

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

喜夏-厌秋 提交于 2019-12-01 03:25:45
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.restoreState(FragmentStatePagerAdapter.java:211) at android.support.v4.view.ViewPager.onRestoreInstanceState

An invisible layout behind the fragment is getting clicked:

我是研究僧i 提交于 2019-11-30 17:15:53
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.slide_out_left, R.anim.slide_in_left, R.anim.slide_out_right) //.hide(mainFragment) .add(R.id.content

Android: remove() Fragment--> add() new Fragment of same class again ->onCreateView and onActivityCreated not called?

这一生的挚爱 提交于 2019-11-30 13:53:00
I am destroying a programmatically created fragment with: getFragmentManager().beginTransaction().remove(getFragmentManager().findFragmentById(R.id.test)).commit(); Which is determined in the xml file like this: <LinearLayout android:id="@+id/test" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent"> </LinearLayout> If I then create a fragment from the same class again in the mainactivity: getSupportFragmentManager().beginTransaction() .add(R.id.result_bar, testinstance) .commit(); Then onCreate seem not called again (the fragment is just