什么是textViewResourceId? [英] What is a textViewResourceId?

查看:287
本文介绍了什么是textViewResourceId?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试从文档中了解如何使用ArrayAdapter类: http ://developer.android.com/reference/android/widget/ArrayAdapter.html ,我看到构造函数期望一个名为textViewResourceId的整数.

I've been trying to figure how the ArrayAdapter class can be used, and from the docs : http://developer.android.com/reference/android/widget/ArrayAdapter.html, I see the constructor expects an integer called textViewResourceId.

这到底是什么?

从更多的研究和这里的答案来看,它似乎必须是我在包含接口代码的xml文件中定义的TextView的ID.但是我在这里看到了这个例子:

From a little more research and the answers here, it looks like it must be the id of a TextView that I defined in the xml file that contains the interface code. But I saw this example here:

ArrAdapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1,myArrayList)

那么如何在这里使用android.R.layout.simple_list_item_1?这到底是什么意思?我只熟悉使用R.id.idOfMyViewHere

So how can android.R.layout.simple_list_item_1 be used here? What does this mean really? I am only familiar with using R.id.idOfMyViewHere

推荐答案

它是textview的ID,适配器将在其中更新您将提供的信息.您可以使用android提供的textview:

it is the id of the textview in which the adapter will update the info you will provide. You can use textview provided by android:

android.R.id.text1

例如

.或者,您也可以提供自己的textView自定义ID

编辑

更改:

ArrayAdapter(this,android.R.layout.simple_list_item_1,myArrayList)

使用

ArrayAdapter(this,android.R.id.text1,myArrayList)

这篇关于什么是textViewResourceId?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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