如何使用FindViewById更新文本视图

发布于 2025-02-06 07:07:04 字数 238 浏览 3 评论 0原文

我正在尝试使用FindViewById()更新文本视图,但是在我的otreate中,我正在调用一个布局,该布局不包括我要更新的文本视图 - 它们是单独的文件。

我已经阅读了FindViewById()的Android开发人员文档,但是我还没有找到如何找到不在相同爆发布局的ID(这意味着我无法使用r.id.callable_textview)。

如何使FindViewById()在未在ongreate上调用的单独布局中找到文本视图?

I am trying to update a TextView by using findViewByID(), but in my onCreate I am calling a layout which does not include the TextView I want to update-they are seperate files.

I have read through the Android Developer Documentation for findViewByID() but I have not found how to find an ID that is not in the same onCreate layout (which means I cannot use R.id.callable_textview).

How can you make findViewById() find the TextView in a seperate layout not called on the onCreate?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月朦胧 2025-02-13 07:07:04

对于活动 a至活动 b的信息,您可以使用 internextent Extras /a>。如果您需要从活动 b回到活动 a,则可以使用 startActivityForresult()

您不应该尝试从另一个活动视图 s active> activity 。那不是它的工作方式。

For passing information from Activity A to Activity B, you can use Intent extras. If you need to pass information from Activity B back to Activity A, you can use startActivityForResult().

You shouldn't be trying to access the Views of one Activity from another Activity. That's not how it works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文