Android – NullPointerException on super. Onstart()

I'm currently writing a fragment that extends the custom sherlockfragment that extends YouTube player support fragment. Unfortunately, the application crashed

Code:

The most interesting thing is that logcat displays the NullPointerException of the trip:

This is logcat:

What's wrong with this code?

resolvent:

It's not clear in the SDK, but as long as I can solve it, you won't extend YouTube player fragment. You just need to include fragments in your layout (it can also be used as nested fragments)

Basically, you have two options:

>Expand YouTube baseactivity and expand the layout containing YouTube playerview – it works, but you can't use fragments > use your favorite activities and inflate the layout containing YouTube playerfragment. Don't extend it

I have successfully added the YouTube player fragment as a nested fragment (update: this will cause some memory leaks, so you may prefer to avoid it). You can add other components around the YouTube player fragment, but please note that because docs means you can't overlay this view with other views when playing the video

Therefore, to solve your problem, please do not extend the YouTube player fragment, just include it in your layout. By calling the initialization of this fragment, you will get a YouTube player in the callback, which you can use to control the video

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>