getSherlockActivity() vs getActivity()

2019-04-20 05:19发布

问题:

I am using SherlockFragment and until today I've always used the getActivity() method to get an instance of the activity hosting the fragment. Now I realiced there's also this method in the SherlockFragment API.. which one should I use?

回答1:

Looks like getSherlockActivity is just a shortcut to:

(SherlockActivity) getActivity()