Android Question TabStripViewPager usage

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Hi
this question concerns a particular usage of TabStripViewPager. From documentation I see that I can only add pages using designer. Now, let's suppose that I have n-pages to add, all equal, with same controls, for example a ListView. Doing this means to apply LoadLayout n times. Therefore, I started from the example:


In the example, 3 different pages are loaded. Instead, I always loaded the same, namely the third page, which has a ListView. I was (wrongly) expecting the list of page 3 to appear in all the 3 pages. What happens is that the list appears only on the third page. I guess that this first example is related to my problem and may be used as an introductory question: why the list appears only on 3rd page?
Then my question is more sophisticate : I have several Pages, each one displaying same List (loaded as a Layout). Of course the Object is the same, but I don't see a way to have a list per each page, being only able to put the list on the page by LoadLayout. I don't see any function to retrieve the ListView object and store it elsewhere (for example in a global List), once it is created by the LoadLayout. In other words, my need is to work on the ListView of each page, selecting the items etc. What I have seen that if I select an item of the ListView in the visible page, while the ItemClick is fired on the right row, the actual ListView is always that of the last page. This is obvious, but, exactly, how to overcome this problem? Again in other words: how to have n Pages, with n ListViews and have a different row selection in each one? Let's suppose I select the 2nd row in first page, and the 4th in the second page. I store the two selections. When I change page, i need to see two different selections ..
Hope to have explained. Thanks in advance for any hint. I attach a test project for the first question. It is the same of the abovementioned link, just loading only 3rd page.
 

Attachments

  • TabStrip.zip
    11.4 KB · Views: 134

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Ciao. Se vedi il progetto capisci. 3 pagine, stessa listView. Supponi di selezionare righe diverse in pagine diverse, e di voler rivedere le tue scelte cambiando pagina.
Hi. Looking the test project should allow you to understand. 3 pages, same ListView. Suppose to select different rows in different pages, and want to see your previous row choice changing page.
My explanation may be confuse, but the problem should be clear.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Ciao. Se vedi il progetto capisci. 3 pagine, stessa listView. Supponi di selezionare righe diverse in pagine diverse, e di voler rivedere le tue scelte cambiando pagina.
Hi. Looking the test project should allow you to understand. 3 pages, same ListView. Suppose to select different rows in different pages, and want to see your previous row choice changing page.
My explanation may be confuse, but the problem should be clear.
I assume not "same ListView" but 3 very similar.
One of the MANY advantages of B4XPages is precisely the fact of maintaining the state of the views.

(Now I'll download your project)
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Ciao. Se vedi il progetto capisci. 3 pagine, stessa listView. Supponi di selezionare righe diverse in pagine diverse, e di voler rivedere le tue scelte cambiando pagina.
Hi. Looking the test project should allow you to understand. 3 pages, same ListView. Suppose to select different rows in different pages, and want to see your previous row choice changing page.
My explanation may be confuse, but the problem should be clear.
Ho aperto il progetto. Non dirmi che vuoi che l'unica ListView si veda in tutte e tre le "pagine" ed in ognuna con una selezione diversa!
Dovresti avere 3 ListView, non una.

Nota che con i progetti B4XPages potresti passare una view, quindi anche una ListView, da una pagina all'altra (che comunque non è ciò che vuoi, visto che vuoi che abbiano selezioni diverse).

---

I opened the project. Don't tell me you want the one ListView to be seen in all three "pages" and in each with a different selection!
You should have 3 ListViews, not one.

Note that with B4XPages projects you could pass a view, therefore also a ListView, from one page to another (which is not what you want anyway, since you want them to have different selections).
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Usually I start from one existing example. This seems to be the latest available. It seems to work for my needs, except for this "detail". I know the B4XPages issues, but I dodn't find any example. Of course I can build from scratch, but this is usually my last option .. Lists are the same, because there is only a LoadLayout to add a page. Nothing else, if I don't miss anything ..
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Ho aperto il progetto. Non dirmi che vuoi che l'unica ListView si veda in tutte e tre le "pagine" ed in ognuna con una selezione diversa!
Dovresti avere 3 ListView, non una.

Nota che con i progetti B4XPages potresti passare una view, quindi anche una ListView, da una pagina all'altra (che comunque non è ciò che vuoi, visto che vuoi che abbiano selezioni diverse).

---

I opened the project. Don't tell me you want the one ListView to be seen in all three "pages" and in each with a different selection!
You should have 3 ListViews, not one.

Note that with B4XPages projects you could pass a view, therefore also a ListView, from one page to another (which is not what you want anyway, since you want them to have different selections).
Of course the ListView is the same, it is obvious. And it is obvious that I should have 3 lists. The problem is that it is no way to do it, because I can only add Pages with LoadLayout..
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Maybe I am saying a nonsense, but if the Pager library returned a "reference" to the Loaded ListView, the problem maybe could be resolved. But probably a nonsense..
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Se apri un thread nel forum italiano è meglio.

Come spiegato nel tutorial, devi avere un layout per ogni pagina; nel tuo caso, in ogni layout avrai una ListView (mooolto meglio CustomListView).
Non riesco a capire il problema (colpa dell'inglese, spero ?).

---

If you open a thread in the Italian forum it's better.

As explained in the tutorial, you need to have a layout for each page; in your case, in each layout you will have a ListView (much better CustomListView).
I can't understand the problem ((I hope it's the English's fault ?).
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
I use English forum to have a wider audience. I can open another thread, but you understood the problem, in my opinion. Just try to display same list (yes CustomListView) in the example. Possible or not? I did it, so it is possible. Unluckily I detected the problem now, after adding a lot of stuff. So uploading my real case is complicate.
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
The fact that I display same ListView is due to fact That I populate the list with an "Add Page" option. Initially there are no Pages. I click Add and, after LoadLayout, I populate the listvews. I have one Page with ListView. Then I press again "Add Page". Now I have two pages, with two lists. being the same List, when I change Page, there are no problems, apparently. But clearly any thing I do is always on same Listview, independently from the page where I am. I should have a different ListView on each page. But LoadLayout doesn't return anything usable.
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Your implementation can't work either. How should your globally defined "Page3ListView1" know that you mean the listview on the 2nd page?

The tabstrip is not made for adding the same layout 3 times, because the tabstrip has no possibility to get the base panel on a specific page, like the xCustomListView. The solution to your problem is: Create 3 forms with 3 ListViews that all have a different name and define them globally above.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
The fact that I display same ListView is due to fact That I populate the list with an "Add Page" option. Initially there are no Pages. I click Add and, after LoadLayout, I populate the listvews. I have one Page with ListView. Then I press again "Add Page". Now I have two pages, with two lists. being the same List, when I change Page, there are no problems, apparently. But clearly any thing I do is always on same Listview, independently from the page where I am. I should have a different ListView on each page. But LoadLayout doesn't return anything usable.
Maybe I understood... finally!
You want the user to be able to add new pages, each with their own ListView, but if in the new pages you load the only layout you have...!

If so, your solution should be here:
https://www.b4x.com/android/forum/t...ow-to-add-programmatically.118037/post-738573
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Your implementation can't work either. How should your globally defined "Page3ListView1" know that you mean the listview on the 2nd page?

The tabstrip is not made for adding the same layout 3 times, because the tabstrip has no possibility to get the base panel on a specific page, like the xCustomListView. The solution to your problem is: Create 3 forms with 3 ListViews that all have a different name and define them globally above.
Yes, clearly. The problem is that I don't know how many pages in advance. But it is clear that I used the wrong starting point. Moreover, if I don't miss anything, there are not other starting points. Thanks
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Le B4XPages sono l'ideale per la tua soluzione. Crei una classe-pagina e puoi creare quante istanze (variabili-oggetto) vuoi a runtime!

B4XPages are ideal for your problem. You can create a page-class and you can create as many instances (object variables) as you want at runtime!
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Yes, clearly. The problem is that I don't know how many pages in advance. But it is clear that I used the wrong starting point. Moreover, if I don't miss anything, there are not other starting points. Thanks
My AS_ViewPager + AS_TabMenuAdvanced would be more suitable for this task
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Maybe I understood... finally!
You want the user to be able to add new pages, each with their own ListView, but if in the new pages you load the only layout you have...!

If so, your solution should be here:
https://www.b4x.com/android/forum/t...ow-to-add-programmatically.118037/post-738573
Suppose I have a Page for some customers, whose number is not know. I have a list of fruits, always the same. When a customer arrives, he chooses some fruits from the list. Then a second arrives and chooses others. This is the problem. It works, if you go only "in one direction". As a matter of fact the available list is always the last loaded. But you can't go back to see the choices of previous customers.
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
My AS_ViewPager + AS_TabMenuAdvanced would be more suitable for this task
I have seen it (and maybe didn't understand well). As a matter of fact, it has a simple example,very similar to mine, just adding fixed pages. But maybe it has something that resolves. I will give a better sight.
 
Upvote 0
Top