NullPointerException on listview.getCount() method -
application crashes throwing null
pointer exception on line roomlist.getadapter().getcount()
. need fetch each edit text value listview
, apply computations on it, after searching various posts, have found out solution not working properly.
roomlist = (listview) vi.findviewbyid(r.id.list2); (int = 0; < roomlist.getadapter().getcount(); i++) { view view = roomlist.getchildat(i); edittext edit = (edittext) view.findviewbyid(r.id.editroom); log.d("value each edit text", edit.gettext().tostring()); }
you have npe because roomlist.getadapter()
returns null
. maybe didn't call roomlist.setadapter(listadapter adapter)
.
by way, should change name roomlist
roomlist
, stick java convention. roomlist.getadapter()
@ first glance looks static method call of roomlist
class.
Comments
Post a Comment