我们可以findviewbyid()的元素在主要活动不可用? [英] Can we findviewbyid() of an element not available in the main activity?

查看:82
本文介绍了我们可以findviewbyid()的元素在主要活动不可用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以使用 findviewbyid 元素不属于主要的任务,但另外一个隐藏的活动?

Can we get using findviewbyid an element not part of the main current activity but another hidden activity ?

推荐答案

在为了能够 findViewById 来找到你的查看元素它必须是当前视图层次结构的一部分。否则,你必须使用充气。充气

In order to be able findViewById to find your View element it has to be part of the current view hierarchy. Otherwise you have to use an inflater. The inflater

实例化布局的XML文件到其对应的视图对象。

Instantiates a layout XML file into its corresponding View objects.

通过您可以拨打充气返回的视图对象 findViewById

through the view object returned by the inflater you can call findViewById

这篇关于我们可以findviewbyid()的元素在主要活动不可用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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