java - Error: Non-static method 'findViewById(int)' cannot be referenced from a static context -


i using android studio (beta), , while using java code in 'oncreateview()', error.

listview listview = (listview) findviewbyid(r.id.somelistview); 

this error:

non-static method 'findviewbyid(int)' cannot referenced static context 

how fix this?

assuming have static fragment inner class inside activity: you're trying call activity's findviewbyid() cannot in static inner class doesn't hold reference parent.

in oncreateview() need call on root view inflated, e.g.

 listview listview = (listview) rootview.findviewbyid(r.id.somelistview); 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -