I created a class extending CursorAdapter, i am having problem on the bindView method.
@Override
public void bindView(View v, Context context, Cursor c) {
int colNum = c.getColumnIndex(VidCallDbAdapter.QRLINK);
String colValue = c.getString(colNum);
System.out.println("value>> " + colValue);
TextView name_text = (TextView) v.findViewById(R.id.qr_url);
name_text.setText(colValue);
}
im always getting a NullPointerException in this line
TextView name_text = (TextView) v.findViewById(R.id.qr_url);
It’s weird because i defined qr_url on one of my xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:layout_height="wrap_content"
android:text=""
android:id="@+id/qr_url"
android:gravity="center_vertical"
android:layout_width="fill_parent"
android:textColor="#000000"
android:textSize="12sp">
</TextView>
</LinearLayout>
Did i miss something on the code that’s why it’s a NullPointerException? Thanks in advance.
If you are getting
NullPointerExceptionin this lineit means that
vis null, cause if TextView is not foundnullwould be returned andNullPointerExceptionwould be thrown inSo make sure your
public View newView(...)is overrided correctly.edit
what you should return in newView is