Android Question How to add multiple of "Horizontal CustomListView" inside "Vertical CustomListView" ?

Adamdam

Active Member
Licensed User
Longtime User
Dear all,
Greetings,

How to add multiple of "Horizontal CustomListView" inside "Vertical CustomListView" ?
i.e each "Horizontal CustomListView" seam as raw inside "Vertical CustomListView".

Thanks on advance.
Regards
 

teddybear

Well-Known Member
Licensed User
Hi,
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
 
Upvote 0

teddybear

Well-Known Member
Licensed User
You need to test CLV which IsInitialized instead of NULL in intercept event of the CLVNested module.
B4X:
[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]
 
Last edited:
Upvote 0

Adamdam

Active Member
Licensed User
Longtime User
You 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
Dear 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
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Dear 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
I didn't add any function , the sub tpc_OnInterceptTouchEvent it is in the module CLVNested of the CLVNested.zip which you attached
 
Last edited:
Upvote 0

Adamdam

Active Member
Licensed User
Longtime User
I didn't add any function , the sub tpc_OnInterceptTouchEvent it is in the module CLVNested of the CLVNested.zip which you attached
Dear Mr. teddybear
Ok, I tested your modification ,
But the App. stop with any touch on scroll.
Any other solution please ?
Best regards
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Any other solution please ?
Dear 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.
 

Attachments

  • CLVNestedOriginalCorrectedByMahares.zip
    24.9 KB · Views: 49
Upvote 0

Adamdam

Active Member
Licensed User
Longtime User
Dear 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.
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
 
Upvote 0

Adamdam

Active Member
Licensed User
Longtime User
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
The important answer for this question : How can I get value or index of clicked item ??
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
The important answer for this question : How can I get value or index of clicked item ??
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:
But I still don't like the fact that I had to comment the subs in the CLVNested class module to make it work. SOmething is still not completely right I am doing. The 2 subs I commented to avoid a crash are: Private Sub tpc_OnInterceptTouchEvent and Private Sub GetInnerCLVFromTouch. Maybe someone can check it out. The attached project has all the changes:
B4X:
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
Example of a log:
index in clicked item row: 6
Value of item clicked: 7 Category 2
Overallindex: 16
1676119180447.png
 

Attachments

  • CLVNestedOriginalCorrectedByMahares021123.zip
    47 KB · Views: 65
Last edited:
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
@Mahares your question about the two subs. Pressing buttons below the CLV result in index = -1
Edit: I tried a few things to prevent this but they caused other errors.
 
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Pressing buttons below the CLV result in index = -1
Edit: I tried a few things to prevent this but they caused other errors.
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.
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
I uncommented the subs to try to see why they wouldn't work.
I found it on line 55 of CLVNested where it should have returned False (so views further down the tree would have a chance to respond)

I have also made some minor modifications to Main. Implemented the color tab (similar to image tab). Added a piece in Item_Image_Click to modify label and
show navigation info, since this consumes the event and CLVItem_ItemClick is not executed.

I have never used OnInterceptTouchEvent, so I had to learn about it. It's Saturday and I had some time on my hands.

Also, I like to see @Mahares solutions to things, it is always educational.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I like to see the project with your changes William, because I am stuck now without a better solution. That's why I posted
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
OK I forgot to attach it. I marked my changes with <---- (took out your marks)
edit: in OnInterceptTouchEvent, my change is 2 lines further down than my mark
 

Attachments

  • CLVNestedOriginalCorrectedByMahares.zip
    47.1 KB · Views: 65
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
OnInterceptTouchEvent, my change is 2 lines further down than my mark
The only change I noticed you made in the class module is replace Return False with Return True in Private Sub tpc_OnInterceptTouchEvent
Are there any other changes in that particular class I missed.
 
Upvote 0
Top