B4A Library ProgressRoundButton

The attached project wraps this Github project. You need to have android-support-v4.jar in your additional library folder. You can download it from here. Posting the following:

1. The B4A project demonstrating the use of this library
2. The java code. You need to copy android-support-v4.jar to the libs folder should you want to compile the java code. The libs folder is on the same folder level as the src folder.
3. the B4A library files (jar and xml)

Click on the button to get it going...

1.png


2.png


3.png


Some example code:

B4X:
#Region  Project Attributes
    #ApplicationLabel: ProgressRoundButton
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: landscape
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
  
    Dim t, t1 As Timer

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private prb1 As ProgressRoundButton
    Private cnt As Int = 0
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")
  
    t.Initialize("t", 100)
    t1.Initialize("t1", 1000)
  
    prb1.BackgroundColor = Colors.Blue
    prb1.BackgroundSecondColor = Colors.Green
    prb1.ButtonRadius = 15.0
    prb1.TheTextSize = 25.0
    prb1.CurrentText = "START LOADING DATA"
    prb1.MinProgress = 0
    prb1.MinProgress = 100
    prb1.Progress = 0
    prb1.TextColor = Colors.Red
    prb1.TextCoverColor = Colors.LightGray
    prb1.State = 0
  
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub t_tick
  
    cnt = cnt + 1
    If cnt < 101 Then
        prb1.Progress = cnt
    Else
        cnt = 0
        t.Enabled = False  
        prb1.CurrentText = "PROCESSING DATA"
        prb1.State = 2
        t1.Enabled = True
    End If
  
End Sub

Sub t1_tick
  
    cnt = cnt + 1
    If cnt = 5 Then
        t1.Enabled = False
        cnt = 0
        prb1.CurrentText = "START LOADING DATA"
        prb1.State = 0
    End If
  
End Sub

Sub prb1_button_clicked
  
    Log("Button prb1 clicked")
    prb1.State = 1
    prb1.CurrentText = "BUSY LOADING DATA"
    t.Enabled = True
  
End Sub

ProgressRndBtn
Author:
Johan Schoeman
Version: 1
  • ProgressRoundButton
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetTextColorAnimated (arg0 As Int, arg1 As Int)
    • SetTextSizeAnimated (arg0 As Int, arg1 As Float)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • setProgressText (text As String, progress As Float)
    Properties:
    • Background As Drawable
    • BackgroundColor As Int [write only]
    • BackgroundSecondColor As Int [write only]
    • ButtonRadius As Float
    • Color As Int [write only]
    • CurrentText As CharSequence [write only]
    • Enabled As Boolean
    • Gravity As Int
    • Height As Int
    • Left As Int
    • MaxProgress As Int
    • MinProgress As Int
    • Progress As Float
    • State As Int
    • Tag As Object
    • Text As String
    • TextColor As Int
    • TextCoverColor As Int
    • TextSize As Float
    • TheTextSize As Float [write only]
    • Top As Int
    • Typeface As Typeface
    • Visible As Boolean
    • Width As Int
 

Attachments

  • b4aProgressRoundButton.zip
    8.1 KB · Views: 144
  • TheJavaCode.zip
    46.2 KB · Views: 130
  • ProgressRndBtnLibFiles.zip
    14.7 KB · Views: 157
Last edited:

Daniel-White

Active Member
Licensed User
mmm, I downloaded it, and when I try to run it, the IDE complain with "Layout not available"
I had been checking, and sync the files etc, without any luck. I tested in the traditional google SDK emulator.


** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_activity_create (B4A line: 33)
Activity.LoadLayout("main")
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:208)
at JHS.ProgressRoundButton.main._activity_create(main.java:349)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
at JHS.ProgressRoundButton.main.afterFirstLayout(main.java:102)
at JHS.ProgressRoundButton.main.access$000(main.java:17)
at JHS.ProgressRoundButton.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:54)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:158)
... 17 more
Caused by: java.lang.NoClassDefFoundError: android.support.v4.view.animation.PathInterpolatorCompat
at main.java.com.xiaochen.progressroundbutton.AnimDownloadProgressButton.setupAnimations(AnimDownloadProgressButton.java:154)
at main.java.com.xiaochen.progressroundbutton.AnimDownloadProgressButton.<init>(AnimDownloadProgressButton.java:96)
at progressroundbuttonwrapper.progressRoundButtonWrapper._initialize(progressRoundButtonWrapper.java:61)
... 21 more
 

Johan Schoeman

Expert
Licensed User
mmm, I downloaded it, and when I try to run it, the IDE complain with "Layout not available"
I had been checking, and sync the files etc, without any luck. I tested in the traditional google SDK emulator.

Have you downloaded android-support-v4.jar from the link that I have posted? You might have an older version of this file that does not contain all the necessary classes.
 
Top