public View getView(int position, View convertView, ViewGroup parent) {
// TODO 自动生成的方法存根
WordButton holder;
if(convertView == null) {
convertView = Util.getView(mContext, R.layout.self_ui_gridview_item);
holder = mArrayList.get(position); //取出holder
holder.mIndex = position;
holder.mViewButton = (Button) findViewById(R.id.item_btn);
convertView.setTag(holder); //记录
} else {
holder = (WordButton) convertView.getTag();
}
try{
holder.mViewButton.setText(holder.mWordString);
} catch (NullPointerException e) {
Toast.makeText(mContext, "发生异常啦~~",Toast.LENGTH_LONG).show();
}
return convertView;
}
在捕获的那句,我也不知道为什么要抛出空指针异常啊~
1 回答
已采纳
一个人潇洒的生活
TA贡献1条经验 获得超0个赞
holder.mViewButton = (Button) findViewById(R.id.item_btn);
修改为
holder.mViewButton = (Button) convertView.findViewById(R.id.item_btn);
添加回答
举报
0/150
提交
取消