I have some pages which is loading into viewpager. I want to determine if there any way to find out if user touch the view(inside page) when the page is visible? My view pager page view is something like this Basic1.java and initshape() method as describe. Please let me know any more information is required.
Asked
Active
Viewed 403 times
1 Answers
0
implement following code in a page(fragment) you want to detect touch event.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout containing a title and body text.
ViewGroup rootView = (ViewGroup) inflater
.inflate(R.layout.fragment_slide, container, false);
LinearLayout layout = (LinearLayout)rootView.findViewById(R.id.layout)// get your root layout
layout.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.v(null, "TOUCH EVENT"); // handle your fragment touch here
return false;
}
});
return rootView;
}

Harshal Bhatt
- 731
- 10
- 25
-
will try and let you know the result. – Biswajit Das Apr 02 '16 at 06:42