java - Need to set an adapter to a ListView inside a DialogFragment but I get a null pointer exception with the getView() method? Why? -


i have dialog extends dialogfragment:

public class mycustomdialogfragment extends dialogfragment {  static mycustomdialogfragment newinstance() {     return new mycustomdialogfragment(); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {     view view = inflater.inflate(r.layout.institutional_info_custom_list, container, false);      return view; } } 

and use dialog (it inside onclick listener):

mycustomdialogfragment newfragment = mycustomdialogfragment.newinstance();                 view dialogview = newfragment.getview();                 detaillistview = (listview) dialogview.findviewbyid(r.id.custom_dialog_list);                 final masterdetailarrayadapter adapter = new masterdetailarrayadapter(comehainvestito.this, masteranddetailstatisticsinfolist);                          detaillistview.setadapter(adapter);                 newfragment.show(getfragmentmanager(), "master_detail_dialog");  

masteranddetailstatitiscsinfolist list using custom arrayadapter, problem view of dialogfragment: null! why? read android documentation , getview() returns view of dialog 1 returned oncreateview() overriden method.

so why null pointer exception when trying revocer listview in dialogfragments layout???

sorry not make sense me. explanation appreciated. thanks!

use setarguments() provide dataset adapter dialogfragmet. in dialogfragment override onviewcreated(), retrieve listview, create adapter , set listview


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -