fragmenttransaction

Can't open a fragment from another fragment

情到浓时终转凉″ 提交于 2021-02-10 15:10:32
问题 I have 5 fragments (home, settings, newPost, notifications and profile) inside my Main2Activity . Inside HomeFragment I have a RecyclerView with a lot of post views, every post containing a "open" button which should open a PostFragment . The problem is, I can only use setOnClickListener in RecyclerViewAdapter class, in populateItemRows() method, so when I can't use getActivity() .. HomeFragment: public class HomeFragment extends Fragment{ private RecyclerView recyclerView; private

how to setCustomAnimations for FragmentTransaction on this code

依然范特西╮ 提交于 2020-01-31 13:13:54
问题 i have 5 fragments and I use the following code to setCustomAnimations for FragmentTransaction: FragmentTransaction trans = getFragmentManager().beginTransaction(); trans.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right); but how to setCustomAnimations for this one: @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK ) { if (getSupportFragmentManager().getBackStackEntryCount() == 0) { this.finish(); return

how to setCustomAnimations for FragmentTransaction on this code

若如初见. 提交于 2020-01-31 13:09:49
问题 i have 5 fragments and I use the following code to setCustomAnimations for FragmentTransaction: FragmentTransaction trans = getFragmentManager().beginTransaction(); trans.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right); but how to setCustomAnimations for this one: @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK ) { if (getSupportFragmentManager().getBackStackEntryCount() == 0) { this.finish(); return

how to setCustomAnimations for FragmentTransaction on this code

青春壹個敷衍的年華 提交于 2020-01-31 13:09:06
问题 i have 5 fragments and I use the following code to setCustomAnimations for FragmentTransaction: FragmentTransaction trans = getFragmentManager().beginTransaction(); trans.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right); but how to setCustomAnimations for this one: @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK ) { if (getSupportFragmentManager().getBackStackEntryCount() == 0) { this.finish(); return

IllegalStateException with Android Fragments

早过忘川 提交于 2020-01-23 18:20:15
问题 I have a screen where I want to swap two fragments by hiding and showing ( not replacing them) when certain views are clicked. Here is my code: ... private Fragment currentFragment; ... private void swapFragment(Fragment fragment) { FragmentTransaction ft = getChildFragmentManager().beginTransaction(); if (currentFragment != null && !currentFragment.isHidden()) { ft.hide(currentFragment); } if (!fragment.isAdded()) { ft.add(R.id.fragment_holder, fragment); } else { ft.show(fragment); } ft

IllegalStateException with Android Fragments

大城市里の小女人 提交于 2020-01-23 18:17:55
问题 I have a screen where I want to swap two fragments by hiding and showing ( not replacing them) when certain views are clicked. Here is my code: ... private Fragment currentFragment; ... private void swapFragment(Fragment fragment) { FragmentTransaction ft = getChildFragmentManager().beginTransaction(); if (currentFragment != null && !currentFragment.isHidden()) { ft.hide(currentFragment); } if (!fragment.isAdded()) { ft.add(R.id.fragment_holder, fragment); } else { ft.show(fragment); } ft

Android fragments overlap

自闭症网瘾萝莉.ら 提交于 2020-01-11 13:03:44
问题 I have an activity with two fragments, one to display a list and one to show the details of the clicked item. When starting the app the detail part is something static, once I click an item it should get replaced. The problem is that the old fragment is not being replaced, so both views are on top of each other. My activity layout is: <?xml version="1.0" encoding="utf-8"?> <fragment android:id="@+id/listFragment" android:layout_width="0dp" android:layout_height="match_parent" android:layout

FragmentTransaction animation is working but appears glitchy

时光总嘲笑我的痴心妄想 提交于 2020-01-05 09:06:16
问题 I have managed to get the fragments in my app to move correctly as I want them to, however, there is something inconsistent with the animation. To be more specific: I have an activity with 2 frames, and 3 fragments. Two are stationary, and the third moves from left to right, covering and uncovering the first 2. When the mobile fragment moves, it appears momentarily in its final location before sliding as it should from start to finish (using animation resources slide_in_left, slide_in_right,