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

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -