Skip to content

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented Jul 25, 2025

On iOS you use $.lst_open.deselectItem(0, e.itemIndex) to deselect a clicked item. This method is not needed on Android but also not available in the SDK so you have to add an if OS_IOS all the time.

This PR will just add an empty method to the Android ListView so you can remove the if OS_IOS statement.

@prashantsaini1
Copy link
Contributor

It would be better to trigger the automatic deselection of a ListItem for iOS in the SDK itself as majority of the Ti apps use deselectItem on iOS anyways. It would also make the UX same on Android/iOS by showing a touch-ripple effect on item click and automatically fading it away.

@hansemannn
Copy link
Collaborator

For parity with the current iOS implementation, this is the correct way. Changing the default behavior could be inside future versions then. As it was not requested so far, it seems like low prio though.


// not needed on Android but parity for iOS method call
@Kroll.method
public void deselectItem(int section, int item)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect an empty-function warning or something. Isn't that the case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A debug warning is better here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, if Android does not have the concept, it really should just not be exposed. I thought about it a bit more and think that it's much more clean instead of an empty function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it might be a good empty function as you have to use it on iOS so often and you always have to make the if OS_IOS check before it because it will throw a "method not found" error on Android.

but as you've said: no requests by other people yet, just thought it might be a good convenient method

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just write $.listView.deselectItem?.(event.sectionIndex, event.itemIndex) for that :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants