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

Status
Not open for further replies.

Erel

Administrator
Staff member
Licensed User
How many items are in the list? The code calls DoEvents every 100 items.
 

Smee

Well-Known Member
Licensed User
in main i also have this sub

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

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

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
 

Erel

Administrator
Staff member
Licensed User
Are you sure that InitProgressBar is only called after pbIndexMax is set?
 

Smee

Well-Known Member
Licensed User
this is the code as it now stands

B4X:
Public Sub SetItems(Items As List) As 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

B4X:
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
 

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.
 

Smee

Well-Known Member
Licensed User
Ok,
still not working

in Main Module i have created the following

B4X:
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

B4X:
Public Sub SetItems(Items As List) As 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:

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
B4X:
            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)
 

Erel

Administrator
Staff member
Licensed User
The progress bar in Android 4 is a thin line. Does it get updated?
 

Smee

Well-Known Member
Licensed User
its impossible to see, but the counter ticks over ok

this sub fires correctly

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

Erel

Administrator
Staff member
Licensed User
You will need to upload your project (or a working subset of it)...
 

Erel

Administrator
Staff member
Licensed User
You should not initialize views added with the designer (ProgressBar1).
 

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?
 
Status
Not open for further replies.
Top