나는 내부에 가로축이있는 이미지를 가지고 있습니다. 이제 이미지가 클릭 된 경우 클릭 이벤트를 감지해야합니다. 요컨대, 나는 클릭 된 horizontalalscrollview 안에 배치 된 이미지의 인덱스가 필요합니다.HorizontalScrollView의 Click 이벤트
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bgcolor" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageview1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingRight="20dp"
android:src="@drawable/image1" />
<ImageView
android:id="@+id/imageview2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingRight="20dp"
android:src="@drawable/image2" />
OnTouchListener 이벤트를 재생하려했지만 스크롤하는 동안 트리거되는 중입니다. 그리고 OnClickListener는 아무리 클릭해도 트리거되지 않았습니다.
horizontalScrollView1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
System.out.println("Testing scrollview");
}
});
horizontalscrollview 내부에 존재 클릭 한 이미지의 인덱스를 얻을 수있는 해결 방법이 있습니까? 나는 그것이 "갤러리"위젯을 통해 얻을 수 있다고 생각하지만, API16에서는 사용되지 않습니다. 누구든지 HorizontalScrollView를 통해이를 달성하기위한 접근법을 공유 할 수 있습니까?
당신은 샘플 의사 코드 FO를 공유 할 수 이 접근법? –
@ user1816463 : 업데이트를 참조하십시오. – CommonsWare
감사합니다. @commonsware! 나는이 접근법을 점검하려고 노력할 것이다. –