Android Question reuse Activity

SamuelP

Member
Licensed User
Hello,

in my main-Activity I use this code:

B4X:
Sub listview1_ItemClick (Position As Int, Value As Object)
    CallSubDelayed2(Monatseingabe, "SetKlient", listview1.GetItem(Position))
End Sub

This should (and does) show the "Monatseingabe"-Activity and fill it with data from the database.
When I hit the back-button to return to the Main-Activity and to select another listview-Item, the Monatseingabe-Activity is completly loaded agin (needs long time because it contains a lot of labels).

Is there a way to keep the Monatseingabe-Activity cached? So that I only have to change the content of the views without loading them again?

Samuel
 

SamuelP

Member
Licensed User
Do you mean I should use two panels instead of two activites? This would mean, I can use only one bal-File?
Is there no other solution ?
 
Upvote 0

lemonisdead

Well-Known Member
Licensed User
Longtime User
Is there no other solution ?
Yes they are options : not caching the Activity but the variables used to fill the views. Services (and especially the Starter service) are useful for that task.
For example : the list that fills ListView1 could be created in a service and applied to ListView1 in Activity_Resume.

Note: myself, I do often use a Process_Globals list variable associated to an Activity Globals list variable where I put the Activity's views to be able to manage them directly from inside the services. But that's a bit tricky, not clean at all and outside the range of that simple task (see previous paragraph)
 
Upvote 0
Top