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
Post a Comment