0
Good morning guys, all right? I have the following problem:
I enter the initial Fragment of the app and on this screen I have a Pagerview, when I change Fragment and come back using the BACK BUTTON for the initial Fragment this image some. So I put inside the onBackPressed the code that loads the image and worked, but it can only load when it is the initial Fragment, so I have to know to which Fragment the back brought, I need the id to buy or something to compare:
Example without checking Fragment in Onbackpressed: Fragment A went to Fragment B Fragment B returned to Fragment A WENT WELL!!
now if I do this: Fragment A went to Fragment B Fragment B went to Fragment C When you try to get back to B, you’re gonna get your ass kicked 'cause he doesn’t have the Pagerview that I used to call him.
Then I would like a way to verify which Backpress will take so I can check if it is the same as mine (R.id.nav_prg)
I have a global variable and in the event onResume each fragment Seto this variable. That way I can tell what fragment I was on when the button came back down.
– Reginaldo Rigo
then, but onResume runs after Mainactivity onBackPressed, then I would have no way of knowing if it was Fragment A. Within the main I urge a Fragment A class and use a method, only that!
– Felipe Xavier
I’ve tried calling my way of creating Pagerview in Fragment A’s onResume, but it didn’t work... if it had worked out I wouldn’t even need that method in Mainactivity
– Felipe Xavier
Hmmm. In your logic it seems to me to put in the event onPause which fragment is being closed employee.
– Reginaldo Rigo
I understood little what you want to do. It seems to me a little confused.
– viana
The problem is, I’m creating a radio and the top of it is a Pagerview with the stations, when Swipe changes the station. When starting the application loads the top (Pagerview) in Fragment A, when I switch to Fragment B and go back to Fragment A, the top does not load again, even if I put in the methods onPause, onResume and Onstart the method that starts the top. Now when I use to call the way there in Mainactivity, where is onBackPressed, there it works.
– Felipe Xavier
But then it will always call the top load method, but that top only exists in Fragment A, in case I’m in Fragment C and the onBackPressed goes back to Fragment B will PAU, because only in Fragment A exists!
– Felipe Xavier
That’s why I need to know Fragement’s id that onBackPressed is coming back so I can compare it to Fragment A’s!
– Felipe Xavier