我有以下佈局ViewSwitcher和ListView
<ViewSwitcher>
<LinearLayout>
<ListView />
</LinearLayout>
<LinearLayout>
<ListView />
</LinearLayout>
</ViewSwitcher>
但是當我切換ViewSwitcher(由onTouchListener)的ListView的onItemClickListener在我的佈局也做出響應。我不需要在切換。如何解決它?
這是我的切換器類:
public class MMGViewSwitcher extends ViewSwitcher{
private float startX = 0;
private float startY = 0;
private float endX = 0;
private float endY = 0;
public MMGViewSwitcher(Context context, AttributeSet attrs) {
super(context,attrs);
}
@Override
public boolean onTouchEvent(MotionEvent event)
{
String ActionString="";
switch(event.getActionMasked())
{
case MotionEvent.ACTION_DOWN:
startX = event.getX();
startY = event.getY();
ActionString="ACTION_DOWN";
break;
case MotionEvent.ACTION_MOVE:
ActionString="ACTION_MOVE";
break;
case MotionEvent.EDGE_LEFT:
this.showNext();
break;
case MotionEvent.EDGE_RIGHT:
this.showPrevious();
break;
case MotionEvent.ACTION_UP:
endX = event.getX();
endY = event.getY();
if((startX > endX) && Math.abs(startX-endX)>30){
this.showNext();
}
if((startX < endX) && Math.abs(startX-endX)>30){
this.showPrevious();
}
ActionString="ACTION_UP";
break;
}
return true;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev)
{
onTouchEvent(ev);
return false;
}
}
任何機構都知道答案? – 2012-02-20 12:44:12