Android Question Progress Bar Tutorial

metzeller_2013

Member
Licensed User
Longtime User
Can anybody please post a tutorial on how to use the Progressbar? I am currently using it within a loop, and setting the value of progressbar.progress inside the loop. but the progress bar does not show up. and the app tends to hang.

Any help please....
 

metzeller_2013

Member
Licensed User
Longtime User
Here is my code if any can help tell what am I doing wrong? If I put a bookmark on the progress increment the progressbar shows correct but if i run it continuously the progressbar does not show up....

B4X:
Sub UpdateDefaults
Dim AList,TrList As Cursor
Dim sYear, sMonth,sDay, eYear,eMonth, eDay, cDays,i,x As Int
Dim RelDate As String
Dim StartTicks As Long
Dim PaidAmt As Long
Dim Loan As Long
Dim Prog, NewDef, DaysPaid As Int
Dim WhereFields As Map
Dim Last As Int
WhereFields.Initialize
DateTime.DateFormat="MM-dd-yyyy"
TrList = sqlMain.ExecQuery("SELECT trcode, trdate FROM SFTRMast")
Last = TrList.RowCount
Progress.Progress=0
ShowProgress(True)
For i = 0 To TrList.RowCount-1
    Prog=((i+1)/Last)*100
    Progress.Progress =Prog
    lblMessage.Text ="Updating Defaults, please wait ... " & CStr(Prog) & "%"
    TrList.Position=i
    RelDate = ""
    cDays = 0
        '************************************
        'Parse Date
        '************************************
        RelDate = TrList.GetString("trdate")
        StartTicks = DateTime.DateParse(RelDate)
     
        sDay = DateTime.GetDayOfMonth(StartTicks)
        sMonth = DateTime.GetMonth(StartTicks)
        sYear = DateTime.GetYear(StartTicks)
     
        eDay = DateTime.GetDayOfMonth(DateTime.Now)
        eMonth = DateTime.GetMonth(DateTime.Now)
        eYear = DateTime.GetYear(DateTime.Now)
     
        cDays = DaysOut(sYear,sMonth,sDay,eYear,eMonth,eDay,False)
        Log("Start Day:  " & sMonth & "-" & sDay & "-" & sYear )
        Log("End  Day:  " & eMonth & "-" & eDay & "-" & eYear )
        Log("Covered Days " & cDays)
        '************************************
    AList = sqlMain.ExecQuery("SELECT acnum, twnum, trcode, custno, balance, amort FROM " & _
                              "SFRemask WHERE trcode = '" & TrList.GetString("trcode") & "'")
    If AList.RowCount> 0 Then
        For x = 0 To AList.RowCount-1
            AList.Position = x
            PaidAmt = 0
            Loan = 0
            NewDef = 0
            Loan = AList.Getint("amort") * 100
            PaidAmt = Loan - AList.GetLong("balance")
            DaysPaid = PaidAmt / AList.Getint("amort")
            NewDef = cDays - DaysPaid
            WhereFields.Put("custno", AList.GetString("custno"))
            WhereFields.Put("acnum", AList.GetString("acnum"))
            WhereFields.Put("twnum", AList.GetString("twnum"))
            DBUtils.UpdateRecord(sqlMain,"SFRemask","defdays",NewDef,WhereFields)
            WhereFields.Clear
        Next
    End If
Next
ShowProgress(False)
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…