简体   繁体   中英

horizontalscrollview onclicklistener doesn't get called

i have horizontalscrollview displaying some items. The items are added dynamically. i want to show a alert box when the horizontalscrollview is clicked. there may or may not be any items in the horizontalscrollview so i want the horizontalscrollview to take the cick. But OnClickListener dosint get called

scrolv.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                slowAlert();
            }
        });

showAlert() never gets called

One thing you could do is have the click listener on the view that contains the horizontal scrollsview. Along with this you could have each view in the HSV clickable aswell.

Perhaps the event is being consumed before the click is fired? try using onTouch() instead of onClick().

If the problem is that the other items are consuming the even rather than the scroll you may have to use a loop to add the listener to all the items added to the scroll.

heyy just try this just put ClickListener not on scroll view but on the child of that scroll view like relative or linear layout bcoz all your item in that layout also i think its work. and if you try on screen touch then may be it difficult because all screen work in this idea so try my idea of child layout

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM