Как вы создаете свой экземпляр ClickableListAdapter
?
Когда вы создаете свой адаптер списка, вы должны передать идентификатор ресурса viewId
, это должно быть layout
, которое будет завышено позже.
public ClickableListAdapter(Context context, int viewid, List objects) {
// Cache the LayoutInflate to avoid asking for a new one each time.
mInflater = LayoutInflater.from(context);
mDataObjects = objects;
mViewId = viewid;
Ниже код надувает макет xml, переданный конструктору, и вызывает createHolder
.
view = mInflater.inflate(mViewId, null);
// call the user's implementation
holder = createHolder(view);
Поэтому убедитесь, что при создании экземпляра ClickableListAdapter
вы передаете layout
вместо id
Редактировать
Вы должны создать макет xml со следующим, взятым из предоставленной вами ссылки:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<TextView android:text="Text" android:id="@+id/listitem_text"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
></TextView>
<ImageView android:id="@+id/listitem_icon"
android:src="@drawable/globe2_32x32"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="32px"
android:maxHeight="32px"
>
</ImageView>
</LinearLayout>
Если вы назовете его mylistrow.xml
в каталоге раскладки, вы создадите свой адаптер следующим образом:
adapter = new MyClickableChannelListAdapter(this, R.layout.mylistrow, channelList);
setListAdapter(adapter);