I have a ViewPager that holds views which are added dynamically (inflated from XML) and controlled by a PagerAdapter. The views which are added have some simple EditTexts and a SurfaceView which holds a touchable chart.
In order to drop focus from the EditTexts when the user is paging through the views, I followed this suggestion and added the following to the dynamically added view layout:
android:clickable="true"
android:focusable="true"
android:focusableInTouchMode="true"
That worked perfectly, but it introduced a new problem. The user also needs to be able to touch the chart on the SurfaceView, but the SurfaceView is registering each touch as 2 touches (if I remove the above XML attributes, it works correctly but then I have the EditText focus issue).
I tried different variations of the above XML attributes (making some true and some false), but that didn't produce the desired result. I also tried adding an OnFocusChangeListener to the EditTexts so that the above attributes would be true if any had focus and false otherwise.
I've done some searching but couldn't find what I was looking for - any help would be greatly appreciated.