栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

可点击的列表视图

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

可点击的列表视图

您如何创建的实例

ClickableListAdapter

创建列表适配器时,您必须传递一个资源ID

viewId
,它应该是一个资源ID ,
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);


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/428642.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号