2

I created a ListView in Android, and a corresponding ListActivity. Each individual item in the ListView has just one TextView (I plan to add an image and a CheckBox later).The ListActivity overrides the onListItemClick to perform certain tasks on click of any item on the list.

Heres whats happening -

  • When I first tried clicking on any item, nothing happened.
  • I then tried setting the properties "Focusable" and "Focusable in Touch Mode" to false for the TextView, as mentioned here, here and here. The List items started recognizing clicks, but only when I clicked somewhere away from the TextView. Whenever I tried clicking on the TextView or anywhere near it, it did not work.
  • I also tried changing various attributes like Clickable, but nothing has worked so far.

Any idea what I could be doing wrong ?

Thanks

Community
  • 1
  • 1
Abhinav Manchanda
  • 6,546
  • 3
  • 39
  • 46

2 Answers2

1

After playing around with virtually every attribute in my TextView, I finally found the reason why it was not working. It was because of the attribute android:inputType="text" in my TextView. I'm not sure why I added that piece of code (I probably copied the TextView from one of my other applications), but removing it solves my problem.

Abhinav Manchanda
  • 6,546
  • 3
  • 39
  • 46
  • Thanks for posting your solution, I had the same problem and didn't think at all that inputType="text" could be the problem!! – Adinia Jan 27 '11 at 08:14
0

Class which will listen clicks on ListView should implement interface AdapterView.OnItemClickListener

BSMP
  • 4,596
  • 8
  • 33
  • 44
Barmaley
  • 16,638
  • 18
  • 73
  • 146