问题标签 [android-arrayadapter]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
java - 可以在列表视图的 setListAdapter 或 SimpleAdapter 中显示对象值的 Arraylist?
你好,
我想知道是否可以在 listview 的 setListadapter 或 SimpleAdapter 中显示对象值的 Arraylist?
String ArrayList 工作正常,我只是在用 Object ArrayList 试试运气
字符串数组列表(工作版)@ http://developer.android.com/resources/tutorials/views/hello-listview.html
listview - Listview's ArrayAdapter notifydatasetchanged() very slow redraw
I've a quite simple list with 3 textview fields on each row. We are updating their values every 2 seconds or so with data coming from a background webservice call ( AsyncTask )
We compare the coming values with the current ones, update them accordingly on the Adapter and finally calling notifyDataSetChanged() if needed
The thing is that the redraw gets really slow thus hanging the whole UI when we got more than 3 update rows at once. Of course we are using all ListView well-known optimizations such as the EfficientAdapter approach ( setTag() and holders ), and getViewTypecount()/getItemViewType() . We have also tried to optimize our interface as much as possible with layoutopt and trying to avoid wrap_content widths and heights to lighten things up .
We don't do expensive operations on our updates either, just standard stuff: changing TextView text, textcolor, and backgroundcolor values.
The only weird thing I can see is that getView() is called 3-4-5 times for each row, although I've read all those Romain's messages [1] telling that is nothing wrong with that
Any ideas or hints on how can we speed it up?
Thank you very much!
android - 在列表视图中回收视图,值得吗?
在 android listview 上覆盖 baseadapter 时,您必须实现此方法public View getView(int position, View convertView, ViewGroup parent)
。convertview 是先前在滚动时从列表中推出的视图,并且给出它以便您可以重用该视图而不是创建新视图。
我的问题是,真的有必要重用视图吗?如果只更改一部分数据,我可以理解重用它。但是创建视图的开销真的那么大吗?我见过的每个关于使用列表视图的教程都告诉你回收视图,即使是在像文本视图这样简单的视图上也是如此。
我想我的问题是为什么谷歌决定将此作为该getView
方法的默认行为?
android - Android没有ListView适配器resourceId
基于 Android 中的 Hello-ListView 教程,http://developer.android.com/resources/tutorials/views/hello-listview.html
在
有一个错误,因为没有 R.layout.list_item
以前我按照教程,在 res/layout 文件夹中创建了文件 list_item.xml
它也不适用于不同的名称(main_list_view.xml)
这是完整的来源
更新!啊,现在创建新项目时它的作品!当我在第一个项目中使用 File>new>Android XML File 时,它不起作用,但现在在不同的项目中,我使用 file>new>File,也许这是一个可能的错误?
java - ArrayAdapter 的 getView() 很慢
当用户选择 aListViewItem
时,我正在更改该行的背景图像。这似乎发生得非常缓慢。我不确定为什么?
OnItemClickListener
原始代码:
更新:带有 ViewHolder 模式的适配器
java - 如何在 ArrayAdapter 中一次更新一个视图?
我希望能够访问我的 ArrayAdapter 的视图:
我不确定如何访问它:
我不确定如何获得 ViewGroup 父级?
java - 如何让我的 ArrayAdapter 遵循 ViewHolder 模式?
这是我的 ArrayAdapter。我想通过遵循 ViewHolder 模式来提高效率:
但我不确定如何做到这一点。
更新:ViewHolder 模式
android - CheckBox 两次更改值
我有一个 Android ListView
,其项目有一个复选框。
默认情况下选中该复选框。一旦取消选中,它应该从列表中删除。
问题是它onCheckedChanged
被触发了两次:当我点击复选框以取消选中它时(使用isChecked
false
)和删除项目后(使用isChecked
true
)。
这是我的 ArrayAdapter 的相关代码:
我究竟做错了什么?
android - ListActivity/ListView 内容正在“消失”
我在带有自定义 ArrayAdapter 的 ListActivity 中的 ListView 出现问题。
当 ListActivity 隐藏(暂停,无论如何)时,ArrayAdpater 中存在的数据似乎消失了。旋转工作正常,但我只在 onCreate() 中的 ArrayAdapter 中分配数组,没有其他地方。该数组存储在全局静态中,因此数组本身应该没问题。但是 ListView 似乎在 Activity 生命周期中的 onCreate 之后的某个地方放置了数组。
我认为应该在 onResume()、onStart() 或 onRestart() 之一上重新分配数组,但我正在寻找更具体的原因,因为这种情况很少发生,而且在我的基于 Cursor 的适配器中永远不会发生。
android - 使用 ArrayAdapter (Android) 的列表视图中的双行
我是 android 编程新手,我需要一些帮助。我有以下代码:
我想为列表中的每个条目(城市和国家)显示双行,但我没有运气。使用上面的代码,我只看到国家而不是城市。有什么方法可以将两个适配器都添加到 list_search 以便我可以看到所有数据?
谢谢大家的答案!!