安卓:使用其Android充气列表视图:ID [英] Android: Inflate listview using its android:id

查看:165
本文介绍了安卓:使用其Android充气列表视图:ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道这是可能的,是有可能,我只用它的id夸大一个ListView?谢谢你。

I don't know if this is possible, is it possible for me to inflate a listview using only its id? Thanks.

推荐答案

我想你可能会感到困惑的组件ID和布局ID之间的差异。

I think you may be confused about the difference between a component ID and a layout ID.

一个布局ID是指一种布局的XML文件的名称。例如,如果你有一个名为布局 RES /布局/ home_activity.xml ,其ID将被存储为 R.layout.home_activity

A layout ID refers to the name of a layout XML file. For example, if you have a layout named res/layout/home_activity.xml, its ID would be stored as R.layout.home_activity.

一个组件ID指的是一个用户界面组件的现有布局内的身份。所以,你的 home_activity.xml 布局中,你可能有< TextView的机器人:ID =@ + ID / my_textview/> 。该视图的ID是 R.id.my_textview

A component ID refers to the identity of a UI component inside an existing layout. So, inside your home_activity.xml layout you might have <TextView android:id="@+id/my_textview" />. The ID of that View is R.id.my_textview.

您只能使用充气布局ID布局。 充气的成分标识没有任何意义,除非你抬高布局作为具有特定ID的视图一个孩子。

You can only inflate layouts using a layout ID. 'Inflating' a component ID doesn't make any sense, unless you inflate a layout as a child of a View with a specific ID.

这篇关于安卓:使用其Android充气列表视图:ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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