android如何设置以编程方式准备的arrayAdapter布局 [英] android how to set arrayAdapter layout that prepared programmatically

查看:39
本文介绍了android如何设置以编程方式准备的arrayAdapter布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将自定义列表视图与阵列适配器一起使用.我有这个适配器的布局.但我想以编程方式创建这个适配器的布局.Arrayadapter 将此布局的 id 传递给它的超级.它不接受布局.如何传递布局对象而不是 resourceId?

I am trying to use custom listview with an arrayadapter. I have a layout for this adapter.But I want to create layout of this adapter programmatically.Arrayadapter pass the id of this layout to its super. It doesnt accept layout. How can I pass the layout object instead of resourceId?

super(context, LayoutResourceId, ArrayList);

super(context, LayoutResourceId, ArrayList);

推荐答案

对于 ArrayAdapter,您可能不需要扩展它,只需实例化它并使用它...使用此构造函数:http://developer.android.com/reference/android/widget/ArrayAdapter.html#ArrayAdapter(android.content.Context, int, int)

for the ArrayAdapter you might not need to extend it, just instantiate it and use it...use this constructor: http://developer.android.com/reference/android/widget/ArrayAdapter.html#ArrayAdapter(android.content.Context, int, int)

new ArrayAdapter(context, layoutResourceId,arrayList);

这篇关于android如何设置以编程方式准备的arrayAdapter布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆