• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

findViewById() returning null for VideoView

 
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
 
Ranch Hand
Posts: 202
Android PHP Java
  • 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.

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike, try changing android:src to android:id in
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!