Skip to content
Advertisement

Android Studio ListView Only 1 Time Clickable

I created a class “users” and i add the some names. Next i created a ArrayAdapter for ListView and i connect them. But i wont items only one time clickable. I couldn’t. How can i, in listview items only once time clickable? Show it with a sample code please?

JavaScript

Advertisement

Answer

It can be done in a few ways. But the simplest way for your case is to add a boolean field for clicked items. But note that you need to manage this filed depending on your need. For example if you want the items to be clickable every time your app starts then initially you must set that clicked variables of each user to false.

User class

JavaScript

In the activity where you setup the on item click listener

JavaScript

If you use database or something else and you want to save a user’s clicked state, don’t forget to save or update the modified user object every time you modify the clicked property.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement