在Fragment中的listview的BaseAdapter里,使用showpopuwindow()方法出现空指针异常。程序是没有问题的在getView中加监听调用showpopuwindow(),然后函数里面第一句话 View contentView = LayoutInflater.from(MyFragment.getActivity()).inflate(R.layout.popuplayout, null);这里我是用的,然后就会出现空指针,是我的.view.LayoutInflater.from(里面的内容没有找到),请问这里要怎么修改呢?
MyFragment.getActivity(),是这个出现空指针吧,你用getContext就行
在你的adapter的构造方法里传一个Context进来,LayoutInflater.from()里面参数用传进来的这个
MyFragment.getActivity()
换成
getApplicationContext()