Android Question [SOLVED] Remove focused on items from customlistview

nedium

Active Member
Licensed User
Longtime User
Hello everyone, and thank you for any help you can give me.


I am creating an application that will be used on both touch devices and TV boxes (firetv, etc.), I am removing focus from all the objects that are visible using this code.

QuitarFocused:
Sub QuitarFocused (UV As View)
    Try
    Dim joS As JavaObject = UV
    joS.RunMethod("setFocusable", Array(False))
    joS.RunMethod("setFocusableInTouchMode", Array(False))

    Catch
        Log(LastException)
    End Try
End Sub


but in my application I am using 2 customlistviews that add the items from a 'LoadLayout', and I also remove the focus with the above code.


example:
Dim pan As B4XView = xui.CreatePanel("")
pan.SetLayoutAnimated(0, 0, 0, 96%x, 30%y)
pan.LoadLayout("Lista")
QuitarFocused(pan)
Return pan

The application on touch devices works correctly, but when I use a TV box or a Bluetooth remote control, it takes focus from the items added to the list and I don't want it to take focus.

Is there any possibility of being able to remove all the fucus from all the objects, or a way to find the object that has active focus?

note: I am not using the EditText view, it only happens with the items added to the list, and executing the accept button only clicks on those objects.

Thank you very much for the help. I hope to find a solution
 

nedium

Active Member
Licensed User
Longtime User
I have a solution, (I don't know if it is the correct way or not, but it worked), removing the focus from this object and the list works correctly with a remote control.

I hope it is helpful to someone.



code:
For x=0 To CLV_Pan.Size -1
            Dim dd As CLVItem = CLV_Pan.GetRawListItem(x)
            Dim JO As JavaObject = dd.Panel
            JO.RunMethod("setFocusable",Array As Object(False))
            JO.RunMethod("setFocusableInTouchMode",Array As Object(False))
        Next
 
Upvote 0
Top