Issue
I want to get an item from my ListView and setOnTouchListener for that, the following is my code but I am unable to set it properly.
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View selectedView,
int position, long id) {
Log.d("ON ITEM CLICK...", " ON ITEM CLICK... "+ position);
listView.getChildAt(position).setOnTouchListener(HorizontalListActivity.this);
ViewHolder viewHolder =(ViewHolder)selectedView.getTag();
viewHolder.ivThumbnail.setOnTouchListener(HorizontalListActivity.this);
}
});
The reason I wanted to access the item is that I want to drag it on the screen.
Is there a better way to do what I want?
Solution
I'm in the same situation, and have found something that might work, yet I have not had the time to try it out. The basic idea is to dispatch the touch event to the child, like you did, with getChildAt. You listen for touch events in the listview, and simply if you touched the view you are interested in, dispatch the touch event to it to handle it:
MyControl control = ListViews.getChildAt(position));
control.onTouchEvent(touchEvent);
Answered By - Beraxa Ádám
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.