How can I use B4xLoadingIndicator.show when I clicked the item (it's panel) in customlistview?
I want to show the loading indicator then hide it again after 0.5 sec.
I want to show the loading indicator then hide it again after 0.5 sec.
B4X:Sub clv1_ItemClick (Index As Int, Value As Object) Indicator.Show Sleep(500) Indicator.Hide End Sub
Hi Chris:I already tried this but the indicator only shows at the last item of customlistview
Hi Chris:
It works for me. Make sure the indicator is anchored properly in the designer and not hidden or covered by the xClv items.
My indicator is in the clv layout, outside the clv itself, not in the items layout and I changed its color to other than white. If it still does not work, perhaps Erel can help you or a small project demonstrating it may also helpIndicator is in the cell items designer.
It sounds like you are not loading the items into the clv correctly, post the code or upload a small project that shows how you are loading the items.
My indicator is in the clv layout, outside the clv itself, not in the items layout and I changed its color to other than white. If it still does not work, perhaps Erel can help you or a small project demonstrating it may also help
Sub CustomListView1_ItemClick (Index As Int, Value As Object)
Dim P As B4XView = CustomListView1.GetPanel(Index) 'The base panel for the view - that the layout is loaded into.
Dim LI As B4XLoadingIndicator = P.GetView(0).Tag 'GetView(0) The B4xLoadingIndicator as it's the first view in the layout views tree
LI.Show
Sleep(1500)
LI.Hide
End Sub
Not quite, presumably pItem is a panel, so
GetView(0) will get the pItem,
GetView(0).GetView(0) will get the pStatusItem
GetView(0).GetView(1) will get the lblAdvisoryDate
GetView(0).GetView(2) will get the lblAdvisoryTitle
GetView(1) will get the indicatorListItem
Error occurred on line: 174 (Dashboard)
java.lang.ClassCastException: java.lang.String cannot be cast to b4a.example.b4xloadingindicator
at b4a.example.dashboard$ResumableSub_CustomListView1_ItemClick.resume(dashboard.java:774)
at b4a.example.dashboard._customlistview1_itemclick(dashboard.java:740)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1082)
at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1045)
at b4a.example3.customlistview$ResumableSub_PanelClickHandler.resume(customlistview.java:805)
at b4a.example3.customlistview._panelclickhandler(customlistview.java:748)
at b4a.example3.customlistview._panel_click(customlistview.java:735)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:5675)
at android.view.View$PerformClick.run(View.java:22641)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
I don't know if you find it useful or not, but I never do it this way.thanks a lot! Now I get it, how it works.
Dim p As B4XView = clv1.GetPanel(clvIndex)
For Each v As B4XView In p.GetAllViewsRecursive
If v Is Label then
if v.Tag = "2" Then
do something
Else If v.Tag = "3" then
do something
Endi If
Else If v Is Button then
If v.Tag = "3" Then
do something
End If
Else If v is Panel then
If v.Tag = "25" then
do something
End If
End If
Next
I don't know if you find it useful or not, but I never do it this way.
What I do is assign a tag to each view (label, button, imageview etc.) and check all views looking for the one I want
For example:
Of course you can assign a meaningful name to a tag (it may relate to the view function) or just use numbers. If you use numbers in designer, you have to remember the the number is treated as a string i.e. if v.Tag = "2" Then will work, but if v.Tag = 2 Then will not.B4X:Dim p As B4XView = clv1.GetPanel(clvIndex) For Each v As B4XView In p.GetAllViewsRecursive If v Is Label then if v.Tag = "2" Then do something Else If v.Tag = "3" then do something Endi If Else If v Is Button then If v.Tag = "3" Then do something End If Else If v is Panel then If v.Tag = "25" then do something End If End If Next
I find it easier than trying to remember which view has what index.
Your method is viable too because you do not have to worry about keeping track of the designer tree views indices. Perhaps in this thread 's case, it can be abbreviated like this:find it easier than trying to remember which view has what index.
Dim p As B4XView = CustomListView1.GetPanel(Index)
For Each v As B4XView In p.GetAllViewsRecursive
If v.Tag Is B4XLoadingIndicator Then
Dim x As B4XLoadingIndicator=v.tag
x.Show
Sleep(1500)
x.Hide
End If
Next