Android Tutorial ActionBar / Sliding Pages tutorial

Marc De Loose

Member
Licensed User
Longtime User
HI,

I am trying to get my (sliding pages) to center properly.

Right now I have:

B4X:
Sub UpdatePages
 
    Activity.RemoveAllViews
 
    Dim height As Int = CalculateHeight(True, True)
 
    vp.Initialize("vp", Ettape_Size-1, 100%x, height)
    Activity.AddView(vp.AsView, 0, 0, 100%x, height)
    For i = 1 To Ettape_Size-1
        vp.Panels(i-1).LoadLayout("page1.bal")
        UpdatePanel1(i)
    Next
    vp.ScrollTo(LastKnown-1,False)
 

End Sub

Assigning "vp.Panels(i-1).Left = " or "vp.Panels(i-1).Top =" gives me a java error.

B4X:
java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to anywheresoftware.b4a.BALayout$LayoutParams

Any help is welcome thx/
 
Last edited:

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hello,
if I set this

B4X:
Activity.AddMenuItem("Crash", "bt1")
Activity.AddMenuItem("Documents", "bt2")
Activity.AddMenuItem2("Facebook", "btFace", LoadBitmap(File.DirAssets, "facebook.png"))

the icon in the third menuitem isn't display. It is normal?
 

daemon

Active Member
Licensed User
Longtime User
I want to have full-screen panels.
How can I get rid of tab bar?

Following crashes the example app:
#Region Activity Attributes
#FullScreen: True
#IncludeTitle: False
#End Region
 

KL7000F

Member
Licensed User
Longtime User
Hi,
I come from the "Material Design 1 - Basics" tutorial. Following question:
I have "ShowUpIndicator" set to True. It appears under Android 5.0, an arrow to the left. How can I install the lollipop 3-line symbol ("burger") here?

Second Problem:

The ButtonClicked-Event makes an issue:
B4X:
Sub Globals
    Dim SAB As StdActionBar
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout1")
    Activity.Title = "Title"

    SAB.Initialize("SAB")
    SAB.ShowUpIndicator = True
End Sub


Sub SAB_ButtonClicked
    Log("KlickklackKlackerdieKlack")
End Sub

B4X:
java.lang.NoSuchFieldException: mActionView
    at java.lang.Class.getDeclaredField(Class.java:886)
    at anywheresoftware.b4a.objects.StdActionBar.Initialize(StdActionBar.java:64)
    at test.test.test.main._activity_create(main.java:290)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:173)
    at test.test.test.main.afterFirstLayout(main.java:98)
    at test.test.test.main.access$100(main.java:16)
    at test.test.test.main$WaitForLayout.run(main.java:76)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5221)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
java.lang.NoSuchFieldException: mActionView

Can someone help me?
 
Last edited:

KL7000F

Member
Licensed User
Longtime User
Hi,
the "Activity_ActionBarHomeClick" does not work as well. No error message.
If I initialize StdActionBar and there place an event name, there is the above error message. I use B4A 3.20 and Android 5.00 on Nexus 5.

I load the icon with this code:
B4X:
SAB.Icon = LoadBitmap(File.DirAssets, "flam.png")
No icon visible
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Activity_ActionBarHomeClick is only available in B4A v4.0.
2. Download the latest version of this library to prevent this error from happening. Still the event will not work on Android 5. Only the new Activity event works.
3. Make sure to set the holo theme as explained here: Make your app compatible with Android 5.0 devices
 

KL7000F

Member
Licensed User
Longtime User
Too bad version 4.0 can / want not afford it, because I do not earn any money with my apps and operate more as a hobby. Nevertheless, thanks for the help, will then probably rather stay with the "old style"
 

Scott Heywood

Member
Licensed User
Longtime User
I'm using the sliding panels to display images. I'm using a different layout for each page that holds an new ImageView, with sometimes 20 different pages. Is there a way to use the same ImageView for each page and load the needed image when a new page is displayed? My app continues to crash and I feel like this is because I'm using too many ImageViews. When the activity with the StdViewPager is started all of the layouts along with the images are loaded together and the app crashes. The logs show: Downsampling image due to lack of memory.

Ultimately, I want to be able to swipe through the pages like flashcards, so if there is a better solution I'm open to suggestions. I'm not sure if the StdViewPager was intended for this type of use.

Thanks,
 

freedom2000

Well-Known Member
Licensed User
Longtime User
Thanks a lot for this really nice feature.

It works very well on my nexus 5 under lollipop

I am currently using the holo dark them and the result is great.
My app is dealing with "colors" and I would like to dynamically change the underlying "blue line" under the selected tab, to have it in any color.



Is there an easy way to do it ?

Thanks
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…