B4A Library [Class] SearchView - More powerful alternative to AutoCompleteEditText

Discussion in 'Additional libraries, classes and official updates' started by Erel, Jul 8, 2012.

Thread Status:
Not open for further replies.
  1. Smee

    Smee Well-Known Member Licensed User

    in the Main Module

    Code:
    Sub UpdateProgressBar
       ProgressBar1.Progress= pbCounter
    End Sub
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    How many items are in the list? The code calls DoEvents every 100 items.
     
  3. Smee

    Smee Well-Known Member Licensed User

    in main i also have this sub

    Code:
    Sub InitProgressBar
       
    Dim rflBar As Reflector
       rflBar.Target = ProgressBar1
       rflBar.RunMethod2(
    "setMax", pbIndexMax, "java.lang.int")
    End Sub
    which is called from

    Code:
    Public Sub SetItems(Items As ListAs Object
    Main.pbIndexMax=Items.Size
    CallSub(Main,"InitProgressBar")
     
  4. Smee

    Smee Well-Known Member Licensed User

    just over 12100
     
  5. Smee

    Smee Well-Known Member Licensed User

    i tried taking the conditional if out so the doevents is called every time but it made no difference.
    the progressbar shows as a thin line
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Are you sure that InitProgressBar is only called after pbIndexMax is set?
     
  7. Smee

    Smee Well-Known Member Licensed User

    this is the code as it now stands

    Code:
    Public Sub SetItems(Items As ListAs Object
    Main.pbIndexMax=Items.Size
    CallSub(Main,"InitProgressBar")

       
    Dim startTime As Long 
       startTime = 
    DateTime.Now
       
    'ProgressDialogShow2("Building index...", False)       remarked out
       Dim noDuplicates As Map
       noDuplicates.Initialize
       prefixList.Clear
       substringList.Clear
       
    Dim m As Map
       
    Dim li As List
       
    For i = 0 To Items.Size - 1
          Main.pbIndexMax=i
          
    CallSub(Main,"UpdateProgressBar")
          
    'If i Mod 100 = 0 Then                     remarked out
          DoEvents

    Code:
    mAIN mODULE

    Sub Process_Globals
       
    'These global variables will be declared once when the application starts.
       'These variables can be accessed from all modules.
       Dim SQL As SQL
       
    Dim index As Object
       
    Dim pbIndexMax,pbCounter As Long
    End Sub

    Sub InitProgressBar
       
    Dim rflBar As Reflector
       rflBar.Target = ProgressBar1
       rflBar.RunMethod2(
    "setMax", pbIndexMax, "java.lang.int")
    End Sub

    Sub UpdateProgressBar
       ProgressBar1.Progress= pbCounter
    End Sub
    tHE progressbar is built with designer and called ProgressBar1
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    The activity is considered paused until Activity_Create ends. This means that you cannot call an activity with CallSub from Activity_Create. You will need to move the loading code to Activity_Resume.

    Note that there is not reason to call this method every iteration. It is better to call it every 100 iterations.
     
  9. Smee

    Smee Well-Known Member Licensed User

    Ok,
    still not working

    in Main Module i have created the following

    Code:
    Sub timer1_Tick
       Timer1.Enabled=
    False
       LoadProductList
       BuildDisplayTable   
    End Sub
    the code in timer tick IS executed a second after Activity create is finished

    Timer1.Enabled=True

    Code:
    Public Sub SetItems(Items As ListAs Object
    Main.pbIndexMax=Items.Size
    CallSub(Main,"InitProgressBar")

       
    Dim startTime As Long 
       startTime = 
    DateTime.Now
    '   ProgressDialogShow2("Building index...", False) remmed out
       Dim noDuplicates As Map
       noDuplicates.Initialize
       prefixList.Clear
       substringList.Clear
       
    Dim m As Map
       
    Dim li As List
       
    For i = 0 To Items.Size - 1
          
    If i Mod 100 = 0 Then DoEvents
          Main.pbIndexMax=i
          
    CallSub(Main,"UpdateProgressBar")
    all i see on the screen is a thin line where the progressbar should be
    i have set the size to massive in the designer
    top 300
    width 660
    height 300
    left 40
    enabled=true
    visible =true
    indeterminate = False

    i have put a stop line on the line
    ProgressBar1.Progress= pbCounter
    in main and it is executing.

    i have put the progressbar on a panel but it still just shows as a thin line
     
    Last edited: Jan 21, 2013
  10. Smee

    Smee Well-Known Member Licensed User

    I added another progressbar to the activity with the designer but i get the same thing. a thin line

    I am posting a screenshot
     

    Attached Files:

  11. Erel

    Erel Administrator Staff Member Licensed User

    Can you upload your project?
     
  12. Smee

    Smee Well-Known Member Licensed User

    might be better to email it. where can i send it
     
  13. Erel

    Erel Administrator Staff Member Licensed User

  14. Smee

    Smee Well-Known Member Licensed User

    Ahh I see my problem there.

    Ok I removed the Dim pbCounter As Long from Globals

    And changed this
    Code:
    If i Mod 100 = 0 Then DoEvents
                Main.pbcounter=i
                
    CallSub(Main,"UpdateProgressBar")
                
    Dim item As String
    So I now get a run of numbers correctly when logging.

    However I still just get a thin line as if the height is about 5 dips high


    12103
    12104
    12105
    12106
    12107
    12108
    12109
    12110
    12111
    12112
    12113
    12114
    12115
    12116
    12117
    12118
    12119
    12120
    12121
    12122
    12123
    12124
    12125
    12126
    12127
    12128
    12129
    12130
    12131
    12132
    12133
    Index time: 11777 ms (12134 Items)
     
  15. Erel

    Erel Administrator Staff Member Licensed User

    The progress bar in Android 4 is a thin line. Does it get updated?
     
  16. Smee

    Smee Well-Known Member Licensed User

    its impossible to see, but the counter ticks over ok

    this sub fires correctly

    Code:
    Sub UpdateProgressBar
       
    Log(pbCounter)
       ProgressBar1.Progress= pbCounter
    End Sub
    as you see from the log i posted
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    You will need to upload your project (or a working subset of it)...
     
  18. Smee

    Smee Well-Known Member Licensed User

    ok i have modified the original demo program to show what is happening
     

    Attached Files:

  19. Erel

    Erel Administrator Staff Member Licensed User

    You should not initialize views added with the designer (ProgressBar1).
     
  20. Smee

    Smee Well-Known Member Licensed User

    Thanks Erel,

    All that for a stupid mistake :BangHead:

    The thing is i only added that after i found the program was not working. The original error was elsewhere, got fixed but still would not work cos i left that line in.

    Is there a way to increase the height of the progressbar?
     
Thread Status:
Not open for further replies.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice