开发者

onTouch event problem

In my activity, I have a ScrollView with an OnTouchListener. This scrollView contains some imageViews.

The problem is that when I touch an imageView, the onTouch(view,event) function of the OnTouchListener is called, but the view parameter is the scrollView instead of the imageView. Is it normal? How can I have the real touched view in parameter?

edit:

ScrollView scroll = (ScrollView)findViewById(R.id.affichagefiche_scrollview);
touchListener = new OnTouchScrollListener("---");
scroll.setOnTouchListener(touchListener);
private class OnTouchScrollListener implements OnTouchListener{开发者_高级运维
    public boolean onTouch(View view, MotionEvent event) {
        Log.d("activity", "onTouch: "+view.toString());
    }
}

The logs tells me that the view in parameters is always the scrollView, not a child


try bind OnTouchListener to imageViews or do it by getX,getY coords


it will be more easier if you use setOnItemClickListener to get individual imageView of ScrollView.Then use onItemClick(AdapterView parent, View view, int position, long id).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜