This is a migrated thread and some comments may be shown as answers.

Get a list-item to highlight when tapped

5 Answers 160 Views
ListView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
dash
Top achievements
Rank 1
dash asked on 21 Mar 2017, 08:36 PM

How can I get a list-item to highlight when tapped.

I'd like to change the background color to give some feedback of a tap  and back to normal when released.

This is not selecting an item.

 

5 Answers, 1 is accepted

Sort by
0
Henrique
Top achievements
Rank 1
answered on 21 Mar 2017, 11:12 PM
I'm doing the same thing by changing the css and then calling refresh (listView.refresh())
0
Deyan
Telerik team
answered on 22 Mar 2017, 08:19 AM
Hello,

There is an example of similar scenario in our NativeScript Marketplace demo here:

https://github.com/NativeScript/nativescript-marketplace-demo/tree/release/app/examples/listview/selection

@Henrique, normally, you should not be calling refresh() to highlight the selected item. Please take a look at the thread you've opened on the forums regarding this case.

Thanks!

Regards,
Deyan
Telerik by Progress
Did you know that you can open private support tickets which are reviewed and answered within 24h by the same team who built the components? This is available in our UI for NativeScript Pro + Support offering.
0
Marc
Top achievements
Rank 1
answered on 22 Mar 2017, 09:54 AM

Hello,

 

I'd really like to see, that any touchable view (Layout Container, Button, ListView item,...) is able to inherit the native touch effect (ripple) on Android and iOS.

Right now I am switching a lot between the usual ListView and the RadListView component. On the one hand, I want to use the RadListView because of its extra features like pull to refresh, multiselection etc.... on the other hand I do not want to loose the native ripple effect (on Lollipop and the native touch effect on previous Android versions, also on iOS) when tapping on a list item. Thats why i'm considering to go back to the default ListView component.

I think changing the backgroundColor of the tapped list item does not feel native anymore and that would go against the idea why I want to use the NativeScript framework.

0
dash
Top achievements
Rank 1
answered on 22 Mar 2017, 11:20 AM

Deyan - where in the demo is the tapped effect taking place.

I assume it's in selection-view-model.ts.

I looked at the code and it's more selection specific. On a single tap/release - i'd like the item to change color and back to normal.

 

 

I'm using RadListView with no extra features - but in the item definition I'm turning sections on/off depending on context. How interchangable are RadListView and ListView.

 

 

0
Deyan
Telerik team
answered on 23 Mar 2017, 09:32 AM
Hi,

@Marc, RadListView uses the native RecyclerView component from the Android SDK which does not have the Ripple effect by default. You can easily enable it using the following NativeScript plugin: https://www.npmjs.com/package/nativescript-ripple

@dash if you want to highlight an item only when interacting with it, that would require different events compared to those that drive the selection behavior. We will log this in our TODO list and will provide a way to implement it.

Regards,
Deyan
Telerik by Progress
Did you know that you can open private support tickets which are reviewed and answered within 24h by the same team who built the components? This is available in our UI for NativeScript Pro + Support offering.
Tags
ListView
Asked by
dash
Top achievements
Rank 1
Answers by
Henrique
Top achievements
Rank 1
Deyan
Telerik team
Marc
Top achievements
Rank 1
dash
Top achievements
Rank 1
Share this question
or