• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

findViewById() returning null for VideoView

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Ranch Hand
Posts: 55
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mike, try changing android:src to android:id in
 
reply
    Bookmark Topic Watch Topic
  • New Topic