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

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -