• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

findViewById() returning null for VideoView

 
Mike Tabak
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an activity hosting a fragment defined in fragment_hello_moon.xml. The fragment has a VideoView and start and stop buttons. I can get the Views for the start and stop buttons, but I keep getting null when I try to retrieve the VideoView. It's id is in my R.java file.

My fragment code is



The fragment layout file (fragment_hello_moon) is



And my R.java file is


I can't figure why I'm getting null for findViewById(R.id.hellomoon_videoView); Any help would be greatly appreciated

Mike
 
ibrahim yener
Ranch Hand
Posts: 202
Android Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First thing catch my eye is you are not importing R file.
 
Mike Tabak
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ibrahim yener wrote:First thing catch my eye is you are not importing R file.


Thanks for the reply ibrahim. I don't think I need to include R.java, according to Eclipse the R.id.hellomoon_videoView is resolved since my R.java package is the same as the fragment file's package. However, just for giggles I included it and it did not help.

 
Ira Go
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike, try changing android:src to android:id in
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic