如何访问一个包含视图中的元素在Android的XML布局文件? [英] how to access elements inside an included view in a android xml layout file?

查看:99
本文介绍了如何访问一个包含视图中的元素在Android的XML布局文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个布局,我包括它里面的机器人布局:

I created a layout and I included an android layout inside it :

<include
    layout="@android:layout/simple_list_item_multiple_choice" />

在我的整个观点是夸大我怎么能访问里面的元素 simple_list_item_multiple_choice ?我想有一个TextView,我应该能够使用一个复选框,但什么是他们的ID?

Once my whole view is inflated how can I access the element inside the simple_list_item_multiple_choice ? I guess there are a TextView and a CheckBox that I should be able to use but what's their id ?

编辑:
我是否需要膨胀超过一件事?

Do I need to inflate more than one thing ?

推荐答案

您可以访问它这样做的:

You can access it doing this:

CheckedTextView ctv = (CheckedTextView)findViewById(android.R.id.text1);

这篇关于如何访问一个包含视图中的元素在Android的XML布局文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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