我应该通过什么INT到ArrayAdapter的构造,如果我不使用XML资源? [英] What int should I pass into an ArrayAdapter constructor if I am not using an xml resource?
问题描述
所有构造函数的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 baseArrayAdapter
implementation ofgetView()
, that value should not be used, based upon the current implementation ofArrayAdapter
.这篇关于我应该通过什么INT到ArrayAdapter的构造,如果我不使用XML资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!