android - How to fill list view in fragment activity? -
i trying fill list in fragment return null object reference.(attempt invoke virtual method 'android.view.view android.view.view.findviewbyid(int)' on null object reference
) there code:
public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); person.add(new gender("35ae111", false, "60 km/h")); final listview listview= (listview)getview().findviewbyid(r.id.liste); customadapter customadapter=new customadapter(getactivity(), kisiler); listview.setadapter(customadapter); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflate layout fragment return inflater.inflate(r.layout.fragment_all_vehicles, container, false); } }
you need move things need view oncreateview:
public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); person.add(new gender("35ae111", false, "60 km/h")); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflate layout fragment view view = inflater.inflate(r.layout.fragment_all_vehicles, container, false); final listview listview= (listview)view.findviewbyid(r.id.liste); customadapter customadapter=new customadapter(getactivity(), kisiler); listview.setadapter(customadapter); return view; }
Comments
Post a Comment