내 응용 프로그램에는 listView가 있습니다. 나는 ListView의 헤더 인 ViewFlipper를 가지고있다.ListView의 헤더에있는 ViewFlipper 및 onTouchListener
사용자가 터치하여 슬라이드 할 때 ViewFlipper가보기를 전환하게하고 싶습니다. 또한 ViewFlipper의 항목을 클릭 할 수 있습니다. 내 문제는 내 ListView 또한 스크롤 할 수 있지만 세로 및 클릭 할 수 있습니다. 여기
스키마입니다 :첫째, 나는 OnTouchEvent을 사용했습니다. 사용자가 ViewFlipper의 화면 OUT을 터치하더라도 메서드가 호출되기 때문에 작동하지 않습니다.
이제 OuTouchListener를 사용하면 사용자의 제스처를 가로 챌 수 없으며 알아낼 수 없습니다. 여기
리스트 뷰의 헤더에 대한 XML 코드의 샘플입니다<ViewFlipper
android:id="@+id/flipune"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="3" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageButton
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/itemviewflipper1"
android:layout_width="wrap_content"
android:layout_height="150dp"
android:background="@android:color/transparent"
android:contentDescription="@string/stritemviewflipper" />
<TextView
android:id="@+id/titreviewflipper1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/itemviewflipper1"
android:background="#AA000000"
android:paddingTop="10dip"
android:textColor="#ffffffff"
android:textSize="12dip"
android:textStyle="bold" >
</TextView>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageButton
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/itemviewflipper2"
android:layout_width="wrap_content"
android:layout_height="150dp"
android:background="@android:color/transparent"
android:contentDescription="@string/stritemviewflipper" />
<TextView
android:id="@+id/titreviewflipper2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/itemviewflipper2"
android:background="#AA000000"
android:paddingTop="10dip"
android:textColor="#ffffffff"
android:textStyle="bold" >
</TextView>
</RelativeLayout>
[...]
</ViewFlipper>
그리고 활동에 OnTouchListener 정의 : 내 경우
viewFlipper.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent touchevent) {
switch (touchevent.getAction()) {
case MotionEvent.ACTION_DOWN: {
oldTouchValue = touchevent.getX();
break;
}
case MotionEvent.ACTION_UP: {
float currentX = touchevent.getX();
if (touchevent.getY() < metrics.heightPixels/3) {
if (!viewFlipper.isPressed() && oldTouchValue == currentX) {
openDescriptionArticle(index);
} else {
if (oldTouchValue < currentX) {
viewFlipper.setInAnimation(AnimationHelper
.inFromLeftAnimation());
viewFlipper.setOutAnimation(AnimationHelper
.outToRightAnimation());
viewFlipper.showPrevious();
if (index > 0) {
index--;
} else {
index= 4;
}
}
if (oldTouchValue > currentX) {
viewFlipper.setInAnimation(AnimationHelper
.inFromRightAnimation());
viewFlipper.setOutAnimation(AnimationHelper
.outToLeftAnimation());
viewFlipper.showNext();
if (index < 4) {
index++;
} else {
index = 0;
}
}
}
}
break;
}
}
return false;
}
});
여기서 작성한 내용을 토대로 당신이 달성하고자하는 것은 무엇인지 명확하지 않습니다. – FoamyGuy
대답의 링크를 확인하십시오. http://stackoverflow.com/a/11271615/582571 – rajpara
링크를 확인했지만 문제가 해결되지 않습니다. 사실, 내 listView 스크롤 할 수 및 내 ViewFlipper 슬라이드, 내 ListView 스크롤 할 때 ViewFlipper 다음 또는 이전 항목을 표시하고 ListView 스크롤합니다. 두 작업 모두 작동하지만 한 (ViewFlipper의 ListView를 스크롤 할 때 ViewFlipper를 움직여서는 안되며 ViewFlipper를 슬라이드하면 ListView도 움직여서는 안됩니다). – maxetx