Android Question How to get the Panels from a StdViewPager ?

klaus

Expert
Licensed User
Longtime User
I would like to get the Panels from a StdViewPager in the code.
How can I do it ?

The StdViewPager is added in the code and GetType returns:
anywheresoftware.b4a.objects.StdActionBar$StdViewPager

Using v = Activity.GetView(0) and GetType(v) returns:
android.support.v4.view.ViewPager

Is there a possibility to get the anywheresoftware.b4a.objects.StdActionBar$StdViewPager object from android.support.v4.view.ViewPager ?
 

phukol

Active Member
Licensed User
Longtime User
Also interested in these question.... i am using ahviewpager and wanted to get the current selected panel
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Also interested in these question.... i am using ahviewpager and wanted to get the current selected panel
Your question is different and does not belong to this thread. You are asking abot AHViewPager and @klaus is asking about StdViewPager.

You should have created a own new thread for your question.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
StdViewPager.Panels returns the array of panels.
Yes, I know.
But the problem is when you try to get the view with Activity.GetView(x) it returns
this as the type: android.support.v4.view.ViewPager
and not
anywheresoftware.b4a.objects.StdActionBar$StdViewPager

Attached a small project showing the problem.
 

Attachments

  • TestGetViewStdViewPager.zip
    7.1 KB · Views: 199
Upvote 0

anOparator

Active Member
Licensed User
Longtime User
I see. You can do something like:
1. When you add the view pager to the activity then set the object to the tag property:
B4X:
ViewPager.AsView.Tag = ViewPager
2. In the code module you should check the tag value and if it is set you can get the view pager from the tag.
This seems to be what I've been trying to do.
Activity.NumberOfViews, svpTest.Panels.Length, vpg.Panels.Length and pnlTest1.Length seem to return the view/panel number.

I'm going to try it with an EditText on 2 layout files (after i take a time out).
btw: the .zip file i downloaded didn't have a Code module.
edit: am trying to use stdViewPager (StdActionBar without the Tabs).
 
Upvote 0

anOparator

Active Member
Licensed User
Longtime User
This seems to be what I've been trying to do.
Activity.NumberOfViews, svpTest.Panels.Length, vpg.Panels.Length and pnlTest1.Length seem to return the view/panel number.

I'm going to try it with an EditText on 2 layout files (after i take a time out).
btw: the .zip file i downloaded didn't have a Code module.
edit: am trying to use stdViewPager (StdActionBar without the Tabs).
am getting the currentPage number using 'svpTest.CurrentPage' into the log window.

Is this the same as getting the Panels?
 

Attachments

  • tmp_TestGetViewStdViewPager 2-1875226983.zip
    11.2 KB · Views: 162
Upvote 0
Top