NullpointerException when setting adapter for listview in dialog

前端 未结 3 1378
醉梦人生
醉梦人生 2021-01-26 08:00

I want to display a custom dialog that have a listview inside it. First take a look on my code below.

Dialog:

protected void onPostExecute(String file_ur         


        
3条回答
  •  长情又很酷
    2021-01-26 08:16

    Inflate your view and use the object returned by the inflater to look for the ListView inside the layout

    View view = inflater.inflate(R.layout.dialog_add, null)
    ListView lv = (ListView) view.findViewById(R.id.lvAddDialog); 
    ListviewContactAdapter adapter = new ListviewContactAdapter(getActivity(), listContact);
    lv.setAdapter(adapter);             
    builder.setView(view);
    

提交回复
热议问题