Skip to content Skip to sidebar Skip to footer

Onitemclicklistner Is Not Working Android

i am using listview in android with ratingbar as well as check box, here is my problem,if i am setting onitemclick listner to the listview, it is not working? Please any one can he

Solution 1:

In your xml file............. In checkbox..........

android:focusable="false"

Solution 2:

Yes, I see the exact same thing. If you remove the checkbox and rating bar, then OnItemClick works, but with these widgets in your view, Android thinks the user wants to interact with them.

So instead you have to handle the user click in the view itself (rather than the listview).

OnTouchListenerpressItemListener=newOnTouchListener()
{
    @OverridepublicbooleanonTouch(View arg0, MotionEvent arg1)
    {
HomeActivityha= (HomeActivity) getContext();
ha.handleLocationTouchEvent(position, arg1);
     returnfalse;
    }
}
newView.setOnTouchListener(pressItemListener);

In the above example, HomeActivity is my parent activity. So I handle the user touch event in the custom view and then pass it off to the parent activity where you can do with it what you want. You might also want to handle onLongTouch. Hope this helps.

Post a Comment for "Onitemclicklistner Is Not Working Android"