How to get MotionEvent on touch from View?
public class PhotoGalleryFragment extends Fragment implements View.onTouchListener {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_photo_gallery, container, false);
recyclerPhotoView = (RecyclerView) view.findViewById(R.id.photo_gallery_list);
view.setOnTouchListener(this);
return view;
}
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_MOVE) {
Toast.makeText(getContext(), "Row " + motionEvent.getAction() + " clicked!", Toast.LENGTH_SHORT).show();
return true;
} else
return false;
}
}