Вопрос

According to developers' site View.setClicable(true) should

make the view clickable, false otherwise

, so why is it reversed in real? Only setClicable(false) makes my View clicable. Have I found a mistake in API description?

EVIDENCE:

gridview.getChildAt(position).setClickable(true);

Feel free to try it at home. After this the child in gridview won't be clicable.

Это было полезно?

Решение

I assume the clicking you're referring to is what you can listen to with an OnItemClickListener. This is handled entirely by the GridView (the GridView is also what draws the selector on the view), not the child view. You can control which items the GridView should consider as clickable with isEnabled in your adapter.

When you make the child view clickable it will handle all touch events over it. Because of this the GridView will not be notified of touch events on that view, and as such can't handle the click event.

So your view is perfectly clickable, you'd just have to use an OnClickListener to get notified of the clicks.

Другие советы

I think you have misunderstood what is is saying. It says exactly what you said. You pass true to make the view clickable or false otherwise (i.e to make it not clickable).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top