安卓:实现ViewHolder [英] Android: Implementing ViewHolder
问题描述
我想在我的Android应用程序来实现ViewHolder,但我不断收到这ViewHolder不能被解析为一个类型,没有对进口的任何建议。任何人都知道如何解决这个问题?
I am trying to implement ViewHolder in my Android app, but I keep getting that ViewHolder cannot be resolved to a type, without any suggestions for an import. Anyone know how to get around this?
推荐答案
这是因为 ViewHolder
不是一类就是的在的是Android SDK,你自己做的。
根据我所能<一个href="http://xjaphx.word$p$pss.com/2011/06/16/viewholder-pattern-caching-view-efficiently/">find,一个 ViewHolder
是存储视图(每行一个ListView通常情况下)的较大面积的实现,所以它是一种辅助类和高速缓存机制。这是一款例如我发现在Android开发者有什么 ViewHolder
将包含。
That's because a ViewHolder
is not a class that is from the Android SDK, you make it yourself.
Based on what I can find, a ViewHolder
is an implementation that stores Views (per row in a ListView usually) for a larger area, so it is a sort of helper class and cache mechanism. This is one example I found on Android Developers of what a ViewHolder
would contain.
static class ViewHolder {
TextView text;
TextView timestamp;
ImageView icon;
ProgressBar progress;
int position;
}
然后你可以在实现它 ListAdapter
或同级。
这篇关于安卓:实现ViewHolder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!