Java 如何设置布局视图
如何使用Java 如何设置布局视图,java,android,Java,Android,如何使用LayoutInflater设置布局视图。这意味着我需要查看布局并在其他布局上设置此选项 像这样的 LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(this.LAYOUT_INFLATER_SERVICE); View v = layoutInflater.inflate(R.layout.activity_strona_glowna,null); LinearLayout a = findV
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);
您可以使用addView()方法来实现这一点
a.addView(v);
“findViewById”返回一个视图,请将其转换为
线性布局
LinearLayout a = (LinearLayout)findViewById(R.id.MainLayout);
a.addView(v);
“findViewById”返回一个视图,请将其转换为
线性布局
LinearLayout a = (LinearLayout)findViewById(R.id.MainLayout);
a.addView(v);
我尝试了此操作,但出现了一个错误“无法解析符号'addView'”读取此链接以获取新错误我尝试了此操作,但出现了一个错误“无法解析符号'addView'”读取此链接以获取新错误