3
도움이 필요합니다 ... :-) ListView 용 사용자 지정 어댑터가 있습니다. 항목은 TextViews입니다. 모든 TextView에서 onSingleTap, onFling 및 기타 모든 이벤트를 처리 할 수 있기를 원합니다. 그러나 onDown 이벤트 만 작동합니다! 다른 모든 사람들은 그렇지 않습니다! 나는 왜 그런지 이해하지 못한다. 당신이 사용자 정의 클래스 txtProductGestureDetector
를 사용하는 경우OnFling 및 기타 메서드는 ListView 내 TextView에서 작동하지 않습니다.
public class ListViewAdapter extends BaseAdapter{
...
private GestureDetector txtProductGD;
private View.OnTouchListener txtProductGL;
...
public ListViewAdapter(Context context, ArrayList<Product> products) {
...
txtProductGL = new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
txtProductGD = new GestureDetector(new txtProductGestureDetector((TextView) v));
return txtProductGD.onTouchEvent(event);
}
};
...
}
public View getView(int position, View convertView, ViewGroup parent) {
...
view = inflater.inflate(R.layout.listview_item, null);
TextView textView = (TextView) view.findViewById(R.id.txtProduct);
textView.setOnTouchListener(txtProductGL);
...
}
private class txtProductGestureDetector extends SimpleOnGestureListener {
private TextView textView;
public txtProductGestureDetector(TextView textView) {
this.textView = textView;
}
public boolean onDown (MotionEvent e) {
textView.setText("onDown..."); // IT WORKS!
return false;
}
public boolean onSingleTapConfirmed (MotionEvent e) {
textView.setText("onSingleTapConfirmed..."); // IT DOESN'T WORK!
return false;
}
// ALL OTHER METHODS ARE ALSO DON'T WORK!..
}
}