我有一个ExpandableListView
和一个适配器。
我试着在这里夸大儿童观点:
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
rowView = inflater.inflate(R.layout.list_child, parent, false);
TextView txtListChild = (TextView) rowView.findViewById(R.id.child_header);
ImageView imgListChild = (ImageView) rowView.findViewById(R.id.child_icon);
但ImageView始终为null。我不知道为什么。
textView正常工作,但我无法将Bitmap应用于ImageView。
编辑:我在应用位图时遇到NullPointerException。
这是我的布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="9dip"
android:layout_margin="5dip"
android:background="@drawable/card_ui">
<ImageView
android:id="@+id/child_icon"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_marginRight="6dip"/>
<TextView
android:id="@+id/child_header"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_alignWithParentIfMissing="true"
android:layout_toRightOf="@id/child_icon"
android:gravity="center_vertical"/>
</RelativeLayout>
请帮忙!
编辑:这是我的代码。我在getView
的{{1}}方法中应用了图片和文字。
我的ExpandableListAdapter
中有两个小组。当我按下上面的那个时,它会显示子项目。当我按下较低的一个时,它会立即抛出ExpandableListView
。
答案 0 :(得分:1)
我认为你需要给父母(RelativeLayout)充气,但是有很多缺失的信息。