logo
down
shadow

fragment disappear when came back from tab 3


fragment disappear when came back from tab 3

Content Index :

fragment disappear when came back from tab 3
Tag : android , By : arbeitandy
Date : November 28 2020, 12:01 PM

wish of those help I have an Activity with a ViewPager containing Fragments. the first fragment(book) create a nested fragment(singlebook) when click a button on it. Problem is that the first fragment and its component are gone when i came back from fragment3. I think it is related onSaveState or onDestroy.
viewPager = (ViewPager) findViewById(R.id.vp_12);


adapter = new MyPagerAdapter(fragmentManager, fragments);
    viewPager.setAdapter(adapter);
    tabLayout.setupWithViewPager(viewPager);
viewPager = (ViewPager) findViewById(R.id.vp_12);
viewPager.setOffscreenPageLimit(3);

adapter = new MyPagerAdapter(getChildFragmentManager(), fragments);
    viewPager.setAdapter(adapter);
    tabLayout.setupWithViewPager(viewPager);

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Fragment disappear after coming back from startActivityForResult


Tag : android , By : Mario Tristan
Date : March 29 2020, 07:55 AM
Hope this helps i have a strange problem. , my problem has been solved by changing
 Intent intent = new Intent();
 intent.setType("image/*");
 intent.setAction(Intent.ACTION_GET_CONTENT);
 startActivityForResult(
        Intent.createChooser(intent, “Select Album”,
        Home.GALLERY_REQUEST);
Intent intent = new Intent(Intent.ACTION_PICK,
                        android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, Home.GALLERY_REQUEST);

Replace one fragment with another, go back to previous fragment on toolbar back button press


Tag : android , By : Keniwan
Date : March 29 2020, 07:55 AM
hope this fix your issue Use addToBackStack on the transaction to get the "back" behavior.
Use setCustomAnimations on the transaction to animate your fragment transitions.
        getSupportFragmentManager().beginTransaction()
                .add(R.id.fragment_container, firstFragment)
                .addToBackStack(null)
                .setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left, R.anim.slide_out_right, R.anim.slide_in_left)
                .commit();
        getSupportFragmentManager().popBackStack();
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

    <translate
        android:duration="@android:integer/config_mediumAnimTime"
        android:interpolator="@android:anim/decelerate_interpolator"
        android:fromXDelta="-100%p"
        android:toXDelta="0" />

</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

    <translate
        android:duration="@android:integer/config_mediumAnimTime"
        android:interpolator="@android:anim/decelerate_interpolator"
        android:fromXDelta="100%p"
        android:toXDelta="0" />

</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

    <translate
        android:duration="@android:integer/config_mediumAnimTime"
        android:interpolator="@android:anim/decelerate_interpolator"
        android:fromXDelta="0"
        android:toXDelta="-100%p" />

</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

    <translate
        android:duration="@android:integer/config_mediumAnimTime"
        android:interpolator="@android:anim/decelerate_interpolator"
        android:fromXDelta="0"
        android:toXDelta="100%p" />

</set>
    mToolbar = (Toolbar) view.findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {

        switch (item.getItemId()) {
        case android.R.id.home:

            getSupportFragmentManager().popBackStack();
            return true;
        }

        return false;
     }

Why does EditText in fragment show the same value after navigating to another fragment and back using back button in Kot


Tag : development , By : ziqew
Date : March 29 2020, 07:55 AM
should help you out I'm new to Android development and Kotlin. I have bumped into this problem which confuses me. , Add attribute android:saveEnabled="false" in EditText
<EditText
    android:id="@+id/editText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textPersonName"
    android:background="#999"
    android:textSize="18sp"
    android:textColor="#111"
    android:typeface="normal"
    android:layout_margin="20dp"
    android:padding="10dp"
    android:saveEnabled="false"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    tools:text="Text" />

How to disable the back button press in fragment but allow the fragment itself to implement the back pressing logics


Tag : android , By : Brandon
Date : March 29 2020, 07:55 AM
should help you out Whenever you want to dismiss a Fragment, call getFragmentManager().popBackStackImmediate() instead of onBackPressed().

how to go back to previous fragment on pressing manually back button of individual fragment?


Tag : android , By : ChristianM
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • WebView and Advanced View is Not loading partiucalr URL
  • How to show three dots at the end of text view
  • Is it possible to run macros within Android Studio project?
  • Adding a button with default appearance but changed background color
  • What is best way to show notification at a certain time in Android?
  • Jetifier not working when library uses android component and app uses androidx component
  • How can I write the contents of an image in a filesystem
  • Retrieve a list of images from the Database and display them using a ListView?
  • java.lang.SecurityException: my location requires permission ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION
  • Timer/hourglass wont stop
  • How can I make AndroidX the default library for new Android projects?
  • Is it okay to delete buildToolsVersion android studio because of a warning in the Asyncstorage library?
  • Can I call a class that doesn't have an activity withIntent?
  • Android TextView fontFamily not working when set via TextAppearance
  • Unable to find nearby places
  • Is there any way to launch my application right away without 'Ok Google"?
  • Places api set location biased based on current location
  • Layout Preview is not displaying layout when Material Design is added
  • How do I resolve this diamond problem in Kotlin?
  • How to update the custom value in a view model object
  • How to stop refreshing/re-creating activity when updating Firebase data using setValue?
  • Manifest Permissions vs App Setttings Permissions
  • NumberFormatException in Try-Catch while converting String to Int
  • How to pass observable fields through include tag?
  • Next button on Android keyboard not submitting form
  • Does Firestore support automatic functions for updates?
  • Why app crashing because of a missing dimension (for google maps) only when I apply changes?
  • How to make a grouping, ordering and sorting: Kotlin collection
  • how to use augmented reality to change the color of a qr code once it is detected using with arcore and ml kit firebase
  • how to resolve Firebase projects adding quota problem?
  • Why it Kotlin giving me the wrong Int value when converting from a String
  • How to add bottom navigation listeners to fragments
  • Why is scrollview hiding buttons behind other views?
  • Open Settings using Linking.sendIntent()
  • How do I access an unknown node in firebase while retrieving data?
  • Can't retrieve list of all users from firebase authetication
  • many activities with same content (adview, reward adview, functions...) how to avoid repeating code?
  • Popup doesn't hide when touch outside
  • proper way to handling images in Android? by using Firebase
  • Android: Button is faded gray when it should be transparent
  • Gradle DSL method not found: 'deleteAllActions()'
  • In Clean Architecture, must Repository is Android or Kotlin module?
  • Kotlin parse double from string
  • Inconsistency detected. Invalid view holder adapter positionViewHolder
  • In App Update API always returns 1 (UPDATE_NOT_AVAILABLE)
  • Event of ImageView when click
  • Basic precautions to prevent piracy?
  • What is the difference between 'center' and 'centerCrop' in the "ImageView"?
  • Unable to receive SIP calls when app is killed
  • Android emulator not processing http get request, but iOS simulator works fine
  • Android Problem with sharing temporary file
  • How to add Broadcast in Android?
  • How to hide 'Running in Chrome' toast on TWA application on Android devices?
  • How to Fix Error: Could not find method deleteAllActions() for arguments [] on task
  • Android Deep Linking not working with https
  • WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'
  • setSupportActionBar (androidx.appcompat.widget.Toolbar) in AppCompatActivity cannot be applied
  • Manifest merger failed after adding Firebase core version 17.0.0
  • Marker from Firestore map data type
  • Cordova signed apk produces a blank screen after splash screen
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com