简体   繁体   English

如何在运行时多次添加相同的布局;

[英]How to add same layout multiple times during runtime;

I want add issue layout multiple times during run time to an Linear layout I am using below code but layout coming only one time on the screen.please help i am designing e mail like app.based number of emails layout number also changes during run-time please help me. 我想在运行时将问题版式多次添加到线性版式中,我正在使用以下代码,但版式仅在屏幕上出现一次。请帮助我设计类似app的电子邮件。基于电子邮件的数量版式号在运行时也会更改-时间请帮帮我。

for (int i=10;i<14;i++) {
LinearLayout lay = (LinearLayout) findViewById(R.id.veticaltoinsert);
View child = getLayoutInflater().inflate(R.layout.issuelayout, null);
child.setId(i);
lay.addView(child);
}

Since the you are going to be displaying a list of emails, why not use a ListView with a custom adapter and layout for the for the emails being displayed in the list. 由于您将要显示电子邮件列表,所以为什么不使用带有自定义适配器和列表布局的ListView来显示列表中的电子邮件。

Have a look at this , it should help you out. 看看这个 ,它应该对您有帮助。

You need a listview or recyclerview here. 您在这里需要一个listview或recyclerview。 Using them you can define layout for a single item and can repeat it using adapters. 使用它们,您可以定义单个项目的布局,并可以使用适配器重复该布局。

Official tutorial 官方教程

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

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