Doubt about selection of items in Listview

Asked

Viewed 56 times

0

How do I stop when I "click" on the Android "Back" icon I deselect all Listview items instead of terminating Activity?

  • Overwrite back event must resolve, no?

  • If I want to overwrite this method in a frament, it’s the same?

  • I suppose so.

1 answer

2


Click the back icon, I imagine it is the default back of OS Android, correct?

To do this, you must do the override of function onBackPressed within the Activity that you want the default behavior to be changed (or added more things).

So within the function onBackPressed you take the selection of all your items through your Adapter used to popular the Listview.

OBS IMPORTANTE

It is neither healthy nor encouraged, let alone recommended that the standard events of an OS be overwritten in a way that alters its default behavior.

People who use android are used to clicking the back to perform certain action, change this can cause a discomfort in the users of your APP (games are exception).

Just a hint of mobile development patterns.

I hope I’ve helped.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.