gpt4 book ai didi

android - 在 PreferenceActivity 中获取根 ViewGroup

转载 作者:行者123 更新时间:2023-11-29 22:09:32 24 4
gpt4 key购买 nike

我正在尝试在 PreferenceActivity 中实现自定义对话框,该对话框中仍然具有 Android 通用的肯定/中性/否定按钮,即自定义 AlertDialog。这篇文章的底部示例似乎描述了要走的路:Dialogs on Android developer pages .

但是,我找不到一种方法来获取 PreferenceActivity 的根:

View layout = inflater.inflate(R.layout.custom_dialog,
(ViewGroup) findViewById(R.id.??????));

有人知道怎么做吗?

最佳答案

试试这个来获取任何 View 的 Root View

View layout = inflater.inflate(R.layout.custom_dialog,null);
View view = layout.getRootView();

关于android - 在 PreferenceActivity 中获取根 ViewGroup,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9993020/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com