GridView Get Item On Touch

后端 未结 2 631
忘掉有多难
忘掉有多难 2021-02-02 04:23

I\'m trying to get the item selected when i touch a gridview, i cant use the onClick as that starts another activity. What I\'m trying to achieve is to be able to move items in

2条回答
  •  清歌不尽
    2021-02-02 04:59

    If Glendon Trullinger's suggestion of using onLongClickListener isn't sufficient for you, try GridView#pointToPosition(int x, int y), which you can call from a View.OnTouchListener, using the MotionEvent's x and y coordinates. With that position, you can get the child view at that position using this answer, and/or you can get the adapter item itself using AdapterView#getItemAtPosition(int)

提交回复
热议问题