Android Question Focus State with xCustomListView

Baublanc

Member
Licensed User
Longtime User
Allo Everybody, i like to know if we can use the Focus state with xCustomListView one the image, like the evemple below. I need the focus State, because I create an app for Android TV.

Thanks


 

Baublanc

Member
Licensed User
Longtime User
Allo Erel, thanks for the answer, i have about 2000 pictures to load. How to do that with non-lazy load (exemple).

Thanks
 
Upvote 0

Baublanc

Member
Licensed User
Longtime User
Thats the code I use before:

B4X:
Private Sub CreateItem(Width As Int,I As Int) As Panel
    
    Dim p As Panel = xui.CreatePanel("")
    Dim height As Int = Activity.Height/2 + 2dip'   200dip '280dip
    Dim a As Int = DipToCurrent(Activity.Height/2 + 2dip)
    If GetDeviceLayoutValues.ApproximateScreenSize < 4.5 Then height = 310dip
    p.SetLayoutAnimated(0, 0, 0, Width, height)
    p.LoadLayout("Pochette")

    Dim k As Int = 0

    For Each v As View In p.GetAllViewsRecursive
        If v Is Button Then

            Dim bmpTeam1 As BitmapDrawable
            Dim bmpTeam2 As BitmapDrawable
            Dim BitmapTemp1 As Bitmap
            Dim BitmapTemp2 As Bitmap
            BitmapTemp1.Initialize3(ResizeBitmap(bitmaps.Get(i+k),ImageView1.Width -20dip,ImageView1.Height-20dip,True))
            BitmapTemp2.Initialize3(ResizeBitmap(bitmaps.Get(i+k),ImageView1.Width,ImageView1.Height,True))
            bmpTeam1.Initialize(BitmapTemp1)
            bmpTeam1.Gravity= Bit.Or(Gravity.CENTER_VERTICAL, Gravity.CENTER_HORIZONTAL)
            bmpTeam2.Initialize(BitmapTemp2)
            bmpTeam2.Gravity= Bit.Or(Gravity.CENTER_VERTICAL, Gravity.CENTER_HORIZONTAL)
            
            Dim sld As StateListDrawable
            sld.Initialize
            sld.AddState(sld.State_Focused, bmpTeam2)
            sld.AddState(sld.State_Disabled, bmpTeam1)   
            v.Background = sld
            k=k+1
        End If   
    Next

    Dim k As Int = 0
    For Each v As View In p.GetAllViewsRecursive
    
        If v.Tag = "Label" Then
            
            Dim frc As ColorDrawable
            If NoVue.Get(i+k) = 1 Then
                frc.Initialize2(Colors.Transparent, 5dip, 1dip, Colors.Green)
            Else
                frc.Initialize2(Colors.Transparent, 5dip, 1dip, Colors.Red)
            End If
            v.Background = frc
            k=k+1
        End If
        
    Next
    
    Return p
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…