Obtaining the Context in the constructor has (at least) three advantages:
- You only do it once, not every time,
getView()
is called. - You can use it for other purposes too, when needed.
- It also works, when
parent
isnull
.
However, if you don’t have any problems with your solution, you might as well stick to it.