リストビューのフッターとして実際に追加される footer.xml というレイアウトにイメージビューがあります。リストビューの最後に画像を動的に表示する必要があります。
ImageView footerimage;
View footerView = getLayoutInflater().inflate(R.layout.footer, null);//This is the footer layout which i have added to the listview
footerimage = (ImageView)findViewById(R.id.im);
footerimage.setBackgroundResource(images[i]);//images is an integer array which has drawable resources and i value is not null.
lv.addFooterView(footerView, null, false);
上記のコードの 4 行目でヌル ポインター例外が発生しています。また、images[i] を R.drawable.someimage に変更しましたが、NPE はまだ存在しています。以下は私のフッターレイアウトです
<?xml version="1.0" encoding="utf-8"?>
<ImageView
android:id="@+id/im"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:contentDescription="@string/app_name" />
どんな提案でも大歓迎です。よろしくお願いします