简体   繁体   English

如何设置布局视图

[英]How to set View of Layout

How can I set view of layout with using LayoutInflater .如何使用LayoutInflater设置布局视图。 It means i need take view on Layout and set this on other layout这意味着我需要查看布局并将其设置在其他布局上

something like this像这样的东西

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);

i want to set layoutInflater on view of 'a'我想在'a'视图上设置layoutInflater

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

a.addView(v);

'findViewById' returns a view, please convert it to a LinearLayout . '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