Sunday, April 20, 2014

viewpage first row in listview, resulting viewpage not sliding around, how to solve it?


I viewpage in listview first line, and then viewpage will not slide around the

I do not know how to do to make viewpage can be normal in listview sliding around it?
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
The estimated time to rewrite the ListView ListView processed touching their hair down a sliding time not because it is not a ViewGroup View consumer touch time so you do not need to continue the viewpage issued are not receiving touch events (no actual analysis, and may be different or wrong for reference)
Reply:
http://download.csdn.net/detail/shen332401890/5290671
Reply:
How to write ah, how to solve it? ? ?

Reply:
reference to the third floor u010863986 reply:
how to write ah, how to solve it? ? ?


Lateral sliding interception response onTouchEvent event handling on the line

 
public class ViewPagerInListView extends ViewPager {

public ViewPagerInListView (Context context) {
super (context);
}

public ViewPagerInListView (Context context, AttributeSet attrs) {
super (context, attrs);
}

public boolean onInterceptTouchEvent (MotionEvent arg0)
{
/ / When the intercept touch event reaches this position, the return to true,
/ / Description intercept the onTouch this control, and execute this control onTouchEvent
return true;
}

/ ** Touch when you press the point ** /
PointF downP = new PointF ();
/ ** The current touch point ** /
PointF curP = new PointF ();

public boolean onTouchEvent (MotionEvent arg0) {
/ / OnTouch events are recorded each time the current depressed coordinate
curP.x = arg0.getX ();
curP.y = arg0.getY ();

if (arg0.getAction () == MotionEvent.ACTION_DOWN) {
downP.x = arg0.getX ();
downP.y = arg0.getY ();
getParent () requestDisallowInterceptTouchEvent (true);.
}

if (arg0.getAction () == MotionEvent.ACTION_MOVE) {
float dx = Math.abs (arg0.getX ()-downP.x);
float dy = Math.abs (arg0.getY ()-downP.y);

if (dy {
/ / Sentence code is to inform his father ViewPager now proceed to operate the controls is not for me to interfere with the operation of
getParent () requestDisallowInterceptTouchEvent (true);.
}
else
{
getParent () requestDisallowInterceptTouchEvent (false);.
}
}

if (arg0.getAction () == MotionEvent.ACTION_UP) {
getParent () requestDisallowInterceptTouchEvent (false);.

float dx = Math.abs (arg0.getX ()-downP.x);
float dy = Math.abs (arg0.getY ()-downP.y);

if (dy {
/ / Right
if (arg0.getX ()-downP.x> 0)
{
what.getAndAdd (-1);
if (what.get () <0) {
what.getAndAdd (imageViews.size ());
}
viewHandler.sendEmptyMessage (what.get ());
}
else
{
what.incrementAndGet ();
if (what.get ()> imageViews.size () - 1) {
what.getAndAdd (-imageViews.size ());
}
viewHandler.sendEmptyMessage (what.get ());
}
}

if (dx == 0 && dy == 0)
{
Intent intent = new Intent ();
intent.putExtra ("id", "" + curTitleShowId);
intent.putExtra ("title", "" + curTitle);
intent.putExtra ("typeTilte", "" + title);
intent.setClass (act, NewsInfoActivity.class);
act.startActivity (intent);
act.overridePendingTransition (R.anim.push_left_in, R.anim.push_left_out);
}
}
return super.onTouchEvent (arg0);
}
}

No comments:

Post a Comment