I am building a custom listview used to list contacts from the contact cursor into a list with two text view for the phone number and name of the contact as well as a place for the images. I am getting a nullpoint error when i try to setText for my TextView Even though i checked the variable to see if they contained a string I have no ideas whats wrong with it.
public View getView(int position, View convertView, ViewGroup parent) {
View rowView=convertView;
ViewCache viewCache=null;
if (rowView==null) {
LayoutInflater inflater=(LayoutInflater)_context.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
rowView=inflater.inflate(R.layout.row, null);
viewCache = new ViewCache(rowView);
rowView.setTag(viewCache);
}
else {
viewCache=(ViewCache)rowView.getTag();
}
_cursor.moveToPosition(position);
int id = _cursor.getColumnIndex(People._ID);
int numbercolumn = _cursor.getColumnIndex(People.NUMBER);
int namecolumn = _cursor.getColumnIndex(People.NAME);
String tag = "tag";
Log.i(tag, getItem(position).toString());
String name;
String number;
number = _cursor.getString(numbercolumn);
name = _cursor.getString(namecolumn);
Log.i("test6386", number);
Log.i("Test456", name);
TextView nameView = viewCache.getName();
TextView numberView = viewCache.getNumber();
nameView.setText(name);
numberView.setText(number);
Uri uri = ContentUris.withAppendedId(People.CONTENT_URI, _cursor.getLong(id));
Bitmap bitmap = People.loadContactPhoto(_context, uri, R.drawable.icon, null);
viewCache.getIcon().setImageBitmap(bitmap);
return(rowView);
}
I figure it out you have to overwrite the newview and bindview methods
}