gpt4 book ai didi

java - 从布局看

转载 作者:行者123 更新时间:2023-11-29 06:20:28 27 4
gpt4 key购买 nike

我遇到了这个 http://www.brighthub.com/mobile/google-android/articles/48845.aspx

我知道我可以创建 View 。但我想定义一个布局 xml 并将其放入我的 View 中。例如在布局中我会有一些 TextView ,我会动态地为它们设置值并将它们添加到 View 和显示中。如果是的话,这可能吗?如果没有,还有什么选择?

最佳答案

LayoutInflater

示例:

    LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout dialerLayout = (LinearLayout) layoutInflater.inflate(R.layout.phone_dialer, null);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
dialerLayout.setLayoutParams(params);
LinearLayout tabDialer = (LinearLayout) findViewById(R.id.tabDialer);
tabDialer.addView(dialerLayout);

关于java - 从布局看,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3271440/

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