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: 66

Mahares

Expert
Licensed User
Longtime User
Grazie. Sempre utile. Thanks. Always useful.
You started out with TabstripViewPager and ended up with no TabstripViewPager. Although the example that Luca provided you is excellent, you can still achieve your goal with TabstripViewPager using B4XPages style project by having only one B4XPage. If you are fully satisfied, please show us what you got as a final project so we can learn from.
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
You started out with TabstripViewPager and ended up with no TabstripViewPager. Although the example that Luca provided you is excellent, you can still achieve your goal with TabstripViewPager using B4XPages style project by having only one B4XPage. If you are fully satisfied, please show us what you got as a final project so we can learn from.
Hi. To be sincere, i just had the need of a ready and comfortable starting point. Of course I can develop a B4XPages project doing everything by myself. Not necessary to reinvent the wheel and, moreover, I have little time. I choosed TabStripPager because I thought that my problem needed such a way of managing data: I have a main page with general data and then I must generate some pages containing a customlistview. Then I must choose some items from this ListView. Once chosen the item, I must open another Page (by the way another ListView), choose one item of it and finally open another page for actual data. This App may be done in several ways, of course. I decided that a multipage view, just like a "Tab control" in Windows, could be the right way. In this way I had the first page with a button allowing to create others, and, on the top of the Main view, the title of each of these latter pages. Moreover I can navigate between the pages clicking on the title on top. But this navigation is only "apparent", because, as we understood, the ListView appearing on each page is actually always the same. From my programming experiences in MS C++ with MFC, I wrongly thought that I could have a ListView for each page, in some way. In this case not, with the only allowed way of creating it, that is with LoadLayout. It is clear. LucaMS did something different: the list of the Pages is kept in a list which resides on the main page and to access a page it is necessary to select it in the list. It is not like in the Tabbed control, clicking on title. Another way of resolving the problem. There are pro's and contra's. In my opinion, LucaMs suggestion is valid. If I will develop it for my needs, I think impossible to post my final solution, mostly because it will be language dependent. Normally I don't develop general purpose Apps, but only for very narrow client needs. Thanks for reading.
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
BTW also Alexander Stolte Pager is a valid alternative. I must see what is more comfortable in practice, but differences are rather small.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Hi. To be sincere, i just had the need of a ready and comfortable starting point. Of course I can develop a B4XPages project doing everything by myself. Not necessary to reinvent the wheel and, moreover, I have little time. I choosed TabStripPager because I thought that my problem needed such a way of managing data: I have a main page with general data and then I must generate some pages containing a customlistview. Then I must choose some items from this ListView. Once chosen the item, I must open another Page (by the way another ListView), choose one item of it and finally open another page for actual data. This App may be done in several ways, of course. I decided that a multipage view, just like a "Tab control" in Windows, could be the right way. In this way I had the first page with a button allowing to create others, and, on the top of the Main view, the title of each of these latter pages. Moreover I can navigate between the pages clicking on the title on top. But this navigation is only "apparent", because, as we understood, the ListView appearing on each page is actually always the same. From my programming experiences in MS C++ with MFC, I wrongly thought that I could have a ListView for each page, in some way. In this case not, with the only allowed way of creating it, that is with LoadLayout. It is clear. LucaMS did something different: the list of the Pages is kept in a list which resides on the main page and to access a page it is necessary to select it in the list. It is not like in the Tabbed control, clicking on title. Another way of resolving the problem. There are pro's and contra's. In my opinion, LucaMs suggestion is valid. If I will develop it for my needs, I think impossible to post my final solution, mostly because it will be language dependent. Normally I don't develop general purpose Apps, but only for very narrow client needs. Thanks for reading.
I think a B4XPages project is ideal in your case, as each screen is a page-class and you can create as many of them as you want at runtime.

The way you want to be able to navigate between pages you can do however you want; for example you could use your own view to display on each page, even a simple panel with N buttons or a B4XBreadCrumb.
1701597308726.png
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
I think a B4XPages project is ideal in your case, as each screen is a page-class and you can create as many of them as you want at runtime.

The way you want to be able to navigate between pages you can do however you want; for example you could use your own view to display on each page, even a simple panel with N buttons or a B4XBreadCrumb.
View attachment 148281
There is no question about using B4xPages. I was using "old" activity style only because the example was such, and, at the end, exactly for having something similar to the Panel of your last hint. Anyway keeping the list of pages in the first page, as you did, is a good thing in my case. Accessing the page selecting the item in the list pf first page is absolutely a good (and maybe better) alternative to scrolling the Tab style titles on the top.. Maybe they are several tens.. Better your List, in guess. Thanks for the new hint.
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Alexander Stolte Pager is good too, with horizontal sweeping, but not the Page title (which I can add easily of course with a label). The best could be to join the two solutions: your Custom List of Pages on first one, and AS Pager horizontal sweeping.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
There is no question about using B4xPages. I was using "old" activity style only because the example was such, and, at the end, exactly for having something similar to the Panel of your last hint. Anyway keeping the list of pages in the first page, as you did, is a good thing in my case. Accessing the page selecting the item in the list pf first page is absolutely a good (and maybe better) alternative to scrolling the Tab style titles on the top.. Maybe they are several tens.. Better your List, in guess. Thanks for the new hint.
I understand that perhaps you will have many pages and therefore CLV is fine for navigation, but "out of curiosity" I wanted to try using a B4XBreadCrumb. I struggled a bit (!) but in the end I succeeded.
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
I understand that perhaps you will have many pages and therefore CLV is fine for navigation, but "out of curiosity" I wanted to try using a B4XBreadCrumb. I struggled a bit (!) but in the end I succeeded.
To be sincere I have no time for "struggling". BTW, while I was able to go on with your example, I wasn't with AS Pager. My fault of course, but I cannot go around for a perfect UI. At the moment my worry is on data organization. I have understood the basic issues for the U. That's enough for now. Your suggestion was useful. Thanks again.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I understand that perhaps you will have many pages and therefore CLV is fine for navigation, but "out of curiosity" I wanted to try using a B4XBreadCrumb. I struggled a bit (!) but in the end I succeeded.
As you can see, I created 7 pages at runtime but it is not possible to scroll the B4XBreadCrumb.
I'll try to put it in a horizontal ScrollView.

B4XBreadCrumb.jpg
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
As you can see, I created 7 pages at runtime but it is not possible to scroll the B4XBreadCrumb.
I'll try to put it in a horizontal ScrollView.

View attachment 148296
Of course, if what you did is easy to add to your previous example, I can consider to add it to my App (and not for free, to be clear. Your work is valuable, for me). But now it is a little early. The project includes many issues and I must get a global sight before going inside details.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
What I did recently, as in the previous image, is fine if you don't have many pages, otherwise the B4XBreadCrumbs is no good.
I'm trying to make it so that you can scroll through it by putting it in a HorizontalScrollView but a big problem immediately arises: HorizontalScrollView.AddView wants a View, not a B4XView :confused:
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
What I did recently, as in the previous image, is fine if you don't have many pages, otherwise the B4XBreadCrumbs is no good.
I'm trying to make it so that you can scroll through it by putting it in a HorizontalScrollView but a big problem immediately arises: HorizontalScrollView.AddView wants a View, not a B4XView :confused:
In my opinion you should not struggle much on this. Maybe, when we display a page (starting from the second, because the first allows to add others), a "must" could be to swipe horizontally by gesture lib, and change page forward and backward. This could be a nice add on. (same result like you do selecting a page in the first page CLV).. We can go on Italian forum, if you prefer. Staying here your results will benefit more people..
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Pages may be many, perhaps 30 or more. BTW your CLV in first page is very good for managing many pages and, besides "estetical" puppets, it is very effective. But sweeping is a useful add on, in my opinion..
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Pages may be many, perhaps 30 or more. BTW your CLV in first page is very good for managing many pages and, besides "estetical" puppets, it is very effective. But sweeping is a useful add on, in my opinion..
Yes, if you have that many pages CLV is necessary.
To make it nice "you" don't need much work; "you" can use the Add method, instead of AddTextItem and create custom items.
 
Upvote 0
Top