Really, many thanks Eng. Erel
Hi,
Information is not enoughHi,
Greetings,
How can I add Image, text,... in each item of horizontal CLV.
I failed to layout by this command pp.LoadLayout("card") (where card is layout include panel, image, ...)
Any help , please.
best regards
Information is not enough
you'd better post a log or small project
[S][S]Private Sub tpc_OnInterceptTouchEvent (Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
If Action = base.TOUCH_ACTION_DOWN Then
Dim inner As CustomListView = GetInnerCLVFromTouch(X, Y)
'If inner <> Null Then 'Modified it to below'
if inner.IsInitialized Then '<===== Add it =====
ScrollingCLV = inner
ScrollingCLVHorizontal = IsHorizontalCLV
StartOffset = GetOffset(X, Y)
Scrolled = False
ScrollPosition = GetOffset(ScrollingCLV.sv.ScrollViewOffsetX, ScrollingCLV.sv.ScrollViewOffsetY)
Return True
End If
End If
Return False
End Sub[/S][/S]
Dear Mr. teddybearYou need to test CLV which IsInitialized instead of NULL in intercept event of the CLVNested module.
B4X:Private Sub tpc_OnInterceptTouchEvent (Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean If Action = base.TOUCH_ACTION_DOWN Then Dim inner As CustomListView = GetInnerCLVFromTouch(X, Y) 'If inner <> Null Then 'Modified it to below' if inner.IsInitialized Then '<===== Add it ===== ScrollingCLV = inner ScrollingCLVHorizontal = IsHorizontalCLV StartOffset = GetOffset(X, Y) Scrolled = False ScrollPosition = GetOffset(ScrollingCLV.sv.ScrollViewOffsetX, ScrollingCLV.sv.ScrollViewOffsetY) Return True End If End If Return False End Sub
I didn't add any function , the sub tpc_OnInterceptTouchEvent it is in the module CLVNested of the CLVNested.zip which you attachedDear Mr. teddybear
Where I can add this function ?
I added it after Activity_Create () function , it gave me errors, many errors
Kindly can you add it in attached project and re-attached project after your modification, please.
Best regards
Dear Mr. teddybearI didn't add any function , the sub tpc_OnInterceptTouchEvent it is in the module CLVNested of the CLVNested.zip which you attached
Dear Mr. AdamDam:Any other solution please ?
Dear Mr MaharesDear Mr. AdamDam:
I had made some extensive changes to your project to make it work. I hope it suits you. I had to comment 2 subs in CLVNested class module to make it work. Also I made many other changes especially in your placement of the layouts, etc. It works, but you can fine tune it and paly with it.
The important answer for this question : How can I get value or index of clicked item ??Dear Mr Mahares
Really many thanks, it is work well.
Can you kindly, help me in solving these related questions :
- How can I get value or index of clicked item, (where function CLVItem_ItemClick (Index As Int, Value As Object) return same Index, value even in differenet horizontal scroll (different row), all row return index start from 0 to 10 ) So, I can't know the real index of clicked item.
- How can I reference certain item to change it's image ?
- Can I add image (icon) for each category (beside category name).
- Can I add/delete item in certain row after whole CLV constructed ?
many thanks again for your solving my big problem
Best regards
I have modified the project so you can get the index and value of the clicked item. When you click on the image the image changes to a flag of a country image., but I could not get it to change the label to the name of the country. When you click on the item away from the image , it logs the value and index. The value is an array of 3 elements:The important answer for this question : How can I get value or index of clicked item ??
Sub CLVItem_ItemClick (Index As Int, Value As Object)
Log("index in clicked item row: " & Index)
Dim v() As Object = Value
Log($"Value of item clicked: ${v(0)} ${v(1)}"$) '<----
Log("Overallindex: " & v(2))
End Sub
I don't understand why you got an error. I downloaded the project I posted in the previous post and extracted it and ran it by clicking either of those two buttons and it worked. But those 2 subs have to be commented for it to work. If they are not commented, you get the error you got.Pressing buttons below the CLV result in index = -1
Edit: I tried a few things to prevent this but they caused other errors.
The only change I noticed you made in the class module is replace Return False with Return True in Private Sub tpc_OnInterceptTouchEventOnInterceptTouchEvent, my change is 2 lines further down than my mark