Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

How to refresh a fragment after onbackpressed from activity with kotlin

 
Ranch Hand
Posts: 165
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my android App with Kotlin, I have an interface for user Account that display all his personal information such as FullName, Email, Address ... And contains also a button to update user. Account is a fragment and when I click on the update Button I go to the UpdateProfile activity. After I update the user profile, when I click on BackPressed Button to Back to the Account Fragment,the Account Fragment didn't refrech and the new information didn't appear.
So, How to refresh the Account Fragment after onbackpressed from activity ?

I create recreate() function in AccountFragment as follows :

and a companion object :

And, In updateProfile activity, I add in the back press Button a call to recreate funtion :


And, I get the following error :


I would like to know, If my method is correct, If yes How can I correct this error ?


 
Rancher
Posts: 437
7
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will you save data to database? Can't put the retrieve function in  onResume AccountFragment ?
 
Maha Sakka
Ranch Hand
Posts: 165
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Randy Tong wrote:Will you save data to database? Can't put the retrieve function in  onResume AccountFragment ?


I use the shared preference to save the new value
When I debug, the error is in the recreate function

In your opinion, where is the problem ?? I think that it is a a correct function,isn't?
 
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!