Android Question AHViewPager + ViewTagger (is something wrong?)

AscySoft

Active Member
Licensed User
Longtime User
Because is too much to write, and a picture is worth a 1000 words, in short I create a project and two images that describe this "error"
At first all is ok, but after you navigate to tab3 and back to one, tagged elements are lost as in image, but not all the info.
I know that if i set "OffscreenPageLimit" to 2, all is ok. But I don't want this because in my app I have many tabs, with many views.
Is this a problem/limitation in ViewTagger library?
Libs involved: AHViewPager, ViewTagger (all up to date)

PS: I test this in a real huge app, and this behavior is similar. Apart from "OffscreenPageLimit=2,3,4,5 etc" in AHViewPager, what else can I do?
 

Attachments

  • AHViewPager+ViewTagger_error.zip
    8 KB · Views: 290
  • Screenshot_2017-01-27-11-06-01.jpg
    Screenshot_2017-01-27-11-06-01.jpg
    282.2 KB · Views: 352
  • Screenshot_2017-01-27-11-07-08.jpg
    Screenshot_2017-01-27-11-07-08.jpg
    212.6 KB · Views: 303

corwin42

Expert
Licensed User
Longtime User
I don't know what ViewTagger is doing exactly but it seems that the library has problems, when the views containing labels are removed from a layout and are readded later (That is what ViewPager does).

Instead of setting OffscreenPageLimit you can create and destroy the whole page contents in PageCreated and PageDestroyed events and not in Activity_Create:

B4X:
Sub VP_PageCreated (Position As Int, Page As Object)
    Dim p As Panel = Page
    If Position = 0 Then
        AddData(p, True)
    Else
        AddData(p, False)
    End If
End Sub

Sub VP_PageDestroyed (Position As Int, Page As Object)
    Dim p As Panel = Page
   
    p.RemoveAllViews
End Sub
 
Upvote 0

AscySoft

Active Member
Licensed User
Longtime User
Thanks for your answer
I understand the logic, I did change the code, and now the first 2 tabs are loaded (on entry point) then the third one when needed and so on ... obvious that the tagged label is well formatted, but I do not want to requery/readd data from the first, second or third tab over and over again (overheating).
Any ideas?
 
Upvote 0
Top