Android Question CustomListView - How To Add Selector Like ListView Have

ronovar

Active Member
Licensed User
Longtime User
I switch to CustomListView (because ListView makes in imageview fill and i need to be original size of bitmap) i need to have selector that highlight row when i press up or down on remote control (like listview have automatically when you add it to activity).

Here is code that adds my custom panel with items...but i need to have when i run apk that first row is selected (No. 1), when i press down button on remote controll it needs to have selector on (No. 2) and so on.

In listview i use StateListDrawables that works excellent ( i can change stated when row is selected, pressed or normal (BDNormal, BDPressed) so if i can add this StateListDrawables to customlistview it will be excellent (then i can when row is selected change background color, text background etc)

Here is code
 

Attachments

  • CLV.zip
    142.1 KB · Views: 147

mangojack

Expert
Licensed User
Longtime User
This might help .. the click event will recolor the row and reset previous row.

There might be a better solution ...
 

Attachments

  • CLV Test1.zip
    142.5 KB · Views: 138
Upvote 0

ronovar

Active Member
Licensed User
Longtime User
Thanks...i tryed it and not scrolling using remote control (Need code in Activity_KeyPress) but clicking on items works.

Here is code in Activity_KeyPress witch works but when i for example have 14items in one scroll...when i go down 3items it scrools every time down and need to scrool down on every 14item...i think that problem is in sv.ScrollToNow witch scrolls to desired index in scrollview but it scrools whole page so that scrolled item is at top...if you could look at listview scroller how is scrolling when having for example 42items and each page have 14items..when i go down from first item it selects that row...when i go to row 14 and press down button it scrolls to page 2 and selects at top on page 2 row 15...you know what i mean.
 

Attachments

  • CLV3.zip
    142.6 KB · Views: 150
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Try this ... as I dont have the hardware, I used Activity_Click and LongClick to simulate Dpad_Up & Down.
 

Attachments

  • CLV Test2.zip
    142.9 KB · Views: 178
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…