CursorAdapterを継承したクラスを作成しましたが、bindViewメソッドで問題が発生しています。CursorAdapterのbindViewメソッドでNullPointerExceptionが発生しました
@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);
}
イム常にこのライン
のTextViewのname_text =(TextViewの)v.findViewById(R.id.qr_url)でNullPointerExceptionが取得。
私はxr_urlを自分のxmlの1つに定義しているので変です。
<?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>
これはNullPointerExceptionの理由です。前もって感謝します。
あなたの 'newView(View、Context、Cursor)'も投稿してください。 –
これはそれに関連しています。私は私のメソッドに例外があるので、そのメソッドにnullを返しました。 NullPointerExceptionについて説明しています。ありがとう。しかし、そのメソッドのオリジナルコードは@Overrideです。 \t public View newView(Context context、Cursor cursor、ViewGroup parent){ \t \t final LayoutInflater inflater = LayoutInflater.from(context); \t \t戻り値inflater.inflate(layout、parent、false); // \t \t return null; \t} 返品のあるラインで例外があります – androidnewbie
「レイアウト」はどのように定義されていますか?私の編集 – Vladimir