private void sendClickEvent ( final Boolean isLongClick ) { if ( getParent ( ) instanceof AdapterView ) { final AdapterView adapterView = ( AdapterView ) getParent ( ) ; final int position = adapterView . getPositionForView ( this ) ; final long id = adapterView . getItemIdAtPosition ( position ) ; if ( isLongClick ) { if ( adapterView . getOnItemLongClickListener ( ) != null ) adapterView . getOnItemLongClickListener ( ) . onItemLongClick ( adapterView , this , position , id ) ; } else { if ( adapterView . getOnItemClickListener ( ) != null ) adapterView . getOnItemClickListener ( ) . onItemClick ( adapterView , this , position , id ) ; } } }
Send a click event if parent view is a Listview instance