持有人模式接近差异和性能比较
我见过两种方法做同样的事情,我不知道什么更快,什么更好,以及有什么区别。 。 。
我的意思是只有这几行是不同的,其他一切都是一样的,但仍然有两种方法,我不明白有什么不同,哪种方法更快
案例一:
public View getView(int position, View convertView,ViewGroup parent) {
View row=super.getView(position, convertView, parent);
ViewHolder holder=(ViewHolder)row.getTag();
情况二:
public View getView(int position, View convertView,ViewGroup parent) {
//of course some checks if the convertView is null, but that is not the point
ViewHolder holder=(ViewHolder)convertView.getTag();
还有一个子问题:- ) 我如何测试哪个更快?我的意思是我应该如何测试适配器的性能?
谢谢
I have seen two ways of doing the same thing, and I do not know what is faster and what is better , and what is the difference . . .
I mean only this few row at the begging are differences and everything else is the same, but still there are two approaches and I do not understand what is different and which way is faster
case one:
public View getView(int position, View convertView,ViewGroup parent) {
View row=super.getView(position, convertView, parent);
ViewHolder holder=(ViewHolder)row.getTag();
case two:
public View getView(int position, View convertView,ViewGroup parent) {
//of course some checks if the convertView is null, but that is not the point
ViewHolder holder=(ViewHolder)convertView.getTag();
one more sub-question :-)
How can I test what is faster ? I mean how should I do testing for performance on adapters ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不同的是,第一个方法链接到超类,而第二个方法则不是。
使用 Traceview。
What is different is that the first one is chaining to the superclass, and the second one is not.
Use Traceview.