我应该通过什么INT到ArrayAdapter的构造,如果我不使用XML资源? [英] What int should I pass into an ArrayAdapter constructor if I am not using an xml resource?

查看:78
本文介绍了我应该通过什么INT到ArrayAdapter的构造,如果我不使用XML资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有构造函数的ArrayAdapter有你想要实例化视图时使用的布局资源ID int参数。然而有时你要实例从无到有的意见,不使用XML资源。我已经通过android.R.layout.simple_list_item_1在这种情况下,但是这似乎是正确的事情并没有做,如果我不使用该资源。什么是正确的整数在这种情况下通过?


解决方案

  

什么是正确的整数在这种情况下通过?


什么。 0 如果你喜欢。只要你不链接到基 ArrayAdapter 实施的getView(),该值不应使用,根据<一个href=\"https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/widget/ArrayAdapter.java\"相对=nofollow>目前实施 ArrayAdapter

All of the constructors for an ArrayAdapter have an int parameter for the layout resource id you want to use when instantiating views. However sometimes you want to instantiate the views from scratch without using an xml resource. I've been passing android.R.layout.simple_list_item_1 in this situation, but this doesn't seem like the correct thing to do if I'm not using that resource. What is the correct integer to pass in this situation?

解决方案

What is the correct integer to pass in this situation?

Anything. 0 if you like. So long as you are not chaining to the base ArrayAdapter implementation of getView(), that value should not be used, based upon the current implementation of ArrayAdapter.

这篇关于我应该通过什么INT到ArrayAdapter的构造,如果我不使用XML资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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