Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
423 views
in Technique[技术] by (71.8m points)

setOnItemClickListener() not working on custom ListView @ Android

I have Implemented a custom ListView by extending LinearLayout for every row. Every row has a small thumbnail, a text and a check box. The list view is deployed properly and I can scroll and fling through it without any problems.

But The ListView doesn't seem to respond to the setOnItemClickListener() at all, So I had to find a workaround by setting click listener in the getView() of the Text inside every row which is obviously creating problem when I am trying to reuse the adapter. Does anyone have a solution?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try this
For ListView,

final ListView list = (ListView) findViewById(R.id.list);
list.setItemsCanFocus(false);

Also, make sure that for CheckBox inside list item set focusable false

android:focusable="false"
android:focusableInTouchMode="false"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...