繁体   English   中英

如何设置布局视图

[英]How to set View of Layout

如何使用LayoutInflater设置布局视图。 这意味着我需要查看布局并将其设置在其他布局上

像这样的东西

LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(this.LAYOUT_INFLATER_SERVICE);
View v = layoutInflater.inflate(R.layout.activity_strona_glowna,null);
LinearLayout  a = findViewById(R.id.MainLayout);

我想在'a'视图上设置layoutInflater

您可以通过使用 addView() 方法来做到这一点。

a.addView(v);

'findViewById' 返回一个视图,请将其转换为LinearLayout

LinearLayout  a = (LinearLayout)findViewById(R.id.MainLayout);
a.addView(v);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM