Android Question [Solved] ASViewPager - Access to page content

fred-han

Member
Licensed User
Hi,
i try to use ASViewPager to show the content of database records.
It looks very good, but i have the problem to access the actual shown record. I want to edit the record which is visible.
In my testversion i use following code:

B4X:
Class_Globals
    Private ASVP1 As ASViewPager
    Private pnl_for_daten As B4XView
End Sub

Sub SatzEinlesen
For i = 1 To 5
    pnl_for_daten= xui.CreatePanel("")
    pnl_for_daten.SetLayoutAnimated(0,0,0,ASVP1.Base.Width, ASVP1.Base.Height)
    pnl_for_daten.LoadLayout("ly_vorgang_daten")
    
    'Daten einlesen ---
    
    ASVP1.AddPage(pnl_for_daten, i)
Next

End Sub

Everything works fine and all records are shown. I can scroll left and right.
But when i try to edit a field in >pnl_for_daten< i always edit the LAST panel i added.
I tried using .CurrentIndex2 to jump to the item and edit a field. No success.

My problem is that i always use the same layout for every page. And ... the item names are the same in every page.
I don't see a way to address the >actual shown< page.

I think there is a way to do this, but i don't know how.

Thanks in advance

Fred
 

Alexander Stolte

Expert
Licensed User
Longtime User
Upvote 0

fred-han

Member
Licensed User
Hi Alexander,

thanks for the answer. I already used xCLV, but the panels were unique and all fields were unique :)
The listitems have values. And the click_event gives all values.
But i can't access the fields (panels + editfields) in this case.
B4X:
TextField = xCLV.GetPanel(xclv.CurrentIndex).GetView(?)
Do i have to "scan" all fields in the panel with
B4X:
pnl_for_daten.GetAllViewsRecursive
but how do i identify my editfields. I can't use their names.
Give me a hint .....
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Do i have to "scan" all fields in the panel with
No, you build the layout with the designer and each view has a index.
1631131489875.png

If you have a view on a panel then it starts on 0.

This is the reason why I have often demanded that the designer gets numbers for the views, because I have to count every time which index a view has...
 
Upvote 0

fred-han

Member
Licensed User
That was the trick!? Thanks a lot.
Hopefolly i will never forget this appoach. It is really tricky because i often use a "root-panel"and many "section-panel" and most fields lay in "field-panel".
So i have some hirarchical "getview".
Perhaps i will change my kind of design but for this project i need my "field-panels".
Thanks again and i hope ....
"ihr habt genauso schönes Wetter wie wir ....."
Viele Grüße aus Hannover

Fred
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
It is really tricky because i often use a "root-panel"and many "section-panel" and most fields lay in "field-panel".
i feel the pain, my layouts are mostly nested too....
Thanks again and i hope ....
"ihr habt genauso schönes Wetter wie wir ....."
Viele Grüße aus Hannover
Thanks, yes but, "ich bin im Homeoffice, somit merke ich davon heute nichts :) "
 
Upvote 0
Top