LogCat一直给我一个空指针异常。当我尝试在TextView(tview3)中显示“Numbers”时,问题就开始了。 这是我的代码:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
Log.d("context = %s ...", String.valueOf(context));
Log.d("MyAdapter", "getItemId successful");
View row = convertView;
ViewHolder h = null;
if (row == null) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Log.d("MyAdapter", "layout inflater successful");
row = inflater.inflate(R.layout.single_row, parent, false);
h = new ViewHolder(row);
row.setTag(h);
} else {
h = (ViewHolder) row.getTag();
}
Log.d("MyAdapter", "view row successful");
Row temp = rowList.get(position);
h.Course.setText(temp.course);
h.Points.setText(temp.points);
h.CW.setText(temp.credit_weight);
ViewSet vs = new ViewSet();
vs.settingView();
return row;
}
}
class ViewSet extends Activity {
ViewSet() {
}
void settingView() {
setContentView(R.layout.activity_main);
TextView aTextView = (TextView) findViewById(R.id.tview3);
aTextView.setText("Numbers");
}
}