Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] java – how can i hide fragment via a button located inside the same fragment?

Posted on November 11, 2022 By

Solution 1 :

In your MainActivity, add transaction to back stack:


fragmentTransaction.beginTransaction().addToBackStack("scoore");

and then in your fragment pop it from the back stack:

getActivity().getSupportFragmentManager().popBackStack();

Problem :

i’m calling fragment via button within the main activity with this (i’m using bundle to send data here)




String ScoreText ; 
Scooore myFragment = new Scooore();

FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
Bundle data = new Bundle();
data.putString("score", scoreText);
myFragment.setArguments(data);
fragmentTransaction.replace(R.id.showScore, myFragment).commit();



then inside my score fragment i have button there , and i wanna know what code shall i put inside the onClicklistener method there so that button wpild take me back to the main activity

i can use new intent and go back there or even hide the frame layout using setVisibility on it
, but ig maybe there’s better options, right ?

READ  [FIXED] android - Button 3 circle button that can rotate
Powered by Inline Related Posts
Android Tags:android, fragment, java

Post navigation

Previous Post: [FIXED] Unable to connect Firebase in Android Emulator for Flutter Project
Next Post: [FIXED] android – Highlight only one Card in Compose through selection

Related Posts

[FIXED] github – Running sh as part of assembling android project on git action yml Android
[FIXED] How to use Twilio Mobile number for calls and SMS with Android Softphone App Android
[FIXED] how to reformat date in android studio Android
[FIXED] java – how to add coordinates in the segmentation of the watershed? Android
[FIXED] java – Going from fragment to activity with a button. Android Studio Android
[FIXED] count total row of json data using volley android studio Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What is a good substitute for condensed milk?
  • ¿Como el cuerpo te avisa cuando te va a dar un infarto?
  • What is the luxury brand of Jaguar?
  • Who is Big poppa baseball player?
  • What material are foam runners?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme