求大神!android中适配器出现的问题,总是在写入数据时报空指针,网上许多类似都没用,也可能没看出来,
publicViewgetView(intposition,ViewconvertView,ViewGroupparent){NewsSavenews2=getItem(...
public View getView(int position,View convertView,ViewGroup parent){ NewsSave news2=getItem(position); View view; SaveListItem saveItem; LayoutInflater inflater=LayoutInflater.from(getContext());//CheckMap.get(position) if(convertView==null){ //view=LayoutInflater.from(getContext()).inflate(resource, null); view=inflater.inflate(R.layout.news_item, null); saveItem=new SaveListItem(); CheckMap.put(position, view); view.setTag(saveItem); saveItem.newsimage=(ImageView)view.findViewById(R.id.newsimages); saveItem.newstitle=(TextView)view.findViewById(R.id.newstitles); saveItem.newstime=(TextView)view.findViewById(R.id.newstimes); saveItem.newsCheck=(CheckBox)view.findViewById(R.id.checknewss); }else{ view=convertView; saveItem=(SaveListItem)view.getTag(); } saveItem.newstitle.setText(news2.getNewstitle());双击空指针就跳向这里 saveItem.newstime.setText(news2.getNewstime()); saveItem.newsimage.setImageBitmap(news2.getNewsimage1()); saveItem.newsCheck.setChecked(mChecked.get(position)); //以往的消息要在share中判断后在决定能否设为选中状态 //找到需要选中的条目 return view; }
我去,这代码成一团了,(⊙o⊙)… 展开
我去,这代码成一团了,(⊙o⊙)… 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询