Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between the ItemTouchHelper.Callback methods onChildDraw and onChildDrawOver?

The documentation is identical of these two methods:

  • ItemTouchHelper.Callback#onChildDraw
  • ItemTouchHelper.Callback#onChildDrawOver

Should any, both or a specific one be overridden when extending this class and you want to edit how children are drawn? What is the difference? What are the / examples of different use cases? Is the difference similar to the difference between these methods?

  • RecyclerView.ItemDecoration#onDraw
  • RecyclerView.ItemDecoration#onDrawOver
like image 678
Erik Avatar asked Dec 21 '17 13:12

Erik


People also ask

What is a callback function?

A callback function always has a specific action which is bound to a specific circumstance. Therefore, a callback function is only called once a clearly defined operation has been performed. Event handlers are a good example of a type of callback function. These are used in HTML elements such as buttons.

What is the difference between usecallback and usememo?

The major difference between useCallback and useMemo is that useCallback will memory the returned value, whereas useMemo will memory the function. Essentially, the only difference between these hooks is that one caches a value type, and the other caches a function.

How to call a callback as a method in PHP?

To call the callback as a method, proceed as follows: class MyClass { static function myCallbackMethod () { echo 'Hello world!'; } } In PHP, callbacks are a popular way to have functions communicate with each other.


1 Answers

According to this:

...Most of the time, you only need to override onChildDraw but due to limitations of platform prior to Honeycomb, you may need to implement onChildDrawOver as well...

So it's a matter of the API level you are targeting. I think nowadays you should almost always implement just onChildDraw unless your app runs on pre-Honeycomb as well.

like image 178
fmaccaroni Avatar answered Oct 01 '22 19:10

fmaccaroni