I have ListView, where any item is HorizontalLayout on wchich there are 3 TextView. I can realize interface AdapterView.OnItemClickListener:
public void onItemClick(AdapterView parent, View view, final int position, long id) {
final long iid = this.id;
new Thread(
new Runnable() {
public void run() {
long PlaylistId = PlayerServiceBridge.getPlaylistId();
if (PlaylistId == iid)
PlayerServiceBridge.setTrackByPosition(position);
}
}
).start();
开发者_如何转开发 }
Everything is right. But now, I would like to scroll second out of 3 TextView horizontally. I just add some code:
title.setSingleLine(true);
title.setMovementMethod(new ScrollingMovementMethod());
And now, when I click on Item where my TextView is, nothing occurs. When I click and move mouse - text on TextView is scrolled. It's ok. But onItemClick has never been called.
What do I need:
1. I need just listen onItemClick when user just click on Item. 2. When user push down mouse on Item->TextView and then move mouse - just scroll text on thzt TextView. Second point is realized and works well. I need first at the same time with second)
2. Added: public boolean onItemLongClick(AdapterView parent, View view, int position, long id) and public void onItemSelected(AdapterView parent, View view, int position, long id) are correctly listened and handled by my code. Why not onItemSelect?I've had the same problem. The trick is to make the descendants of the LinearLayout
unfocusable. Basically, your LinearLayout
has to have this attribute:
android:descendantFocusability="blocksDescendants"
Your TextView
will still scroll.
精彩评论