Ethan Allen
Ethan Allen

Reputation: 14835

How do I make it ListView not make the click sound in Android?

I have a ListView in my Android app that is partial clickable.... the first 10 rows don't do anything (just display data) and the second 10 are clickable and open a new Activity.

The entire ListView is actually clickable, I just only open an Activity when I detect a touch on a cell that is beyond a certain position. Is this the right way to do this?

Also, because of this, the click sound is played on the device when someone touches ANY row, not just the ones that open an Activity. How do I stop this from happening for certain rows?

Upvotes: 1

Views: 176

Answers (1)

ian.shaun.thomas
ian.shaun.thomas

Reputation: 3488

Override isEnabled as demonstrated below.

class MenuAdapter extends ArrayAdapter<String> {

    ....

    public boolean isEnabled(int position) {
        return position >= 10;
    }
}

This method comes from the BaseAdapter class.

Upvotes: 3

Related Questions