Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
listViewAdapter=new TestListViewAdapter(getActivity(), listBean);
listview.setAdapter(listViewAdapter);
Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
listViewAdapter=new TestListViewAdapter(getActivity(), listBean);
listview.setAdapter(listViewAdapter);
是通过这句初始化:listview=(ListView) view.findViewById(R.id.listview)。并且保证view不为null和id对应存在,如果还有有问题可以把整个类分享出来看下。
另外,建议改用RecyclerView代替ListView,因为它可以实现水平、垂直和瀑布流等布局,用法灵活功能强大。