Есть несколько способов справиться с этим.
1. Используйте тег include.
1.1. Переместите LinearLayout в отдельный файл.
1.2 Добавьте макет с помощью тега include два раза с разными идентификаторами:
<LinearLayout ...>
<include layout="@layout/your_layout" android:id="@+id/first" />
<include layout="@layout/your_layout" android:id="@+id/second" />
</LinearLayout>
1.3 Программно установите содержимое:
View first = findViewById(R.id.first);
first.findViewById(R.id.date).setText("05/05/2020");
View second = findViewById(R.id.second);
second.findViewById(R.id.date).setText("04/04/2020");
2 . Реализовать настраиваемый вид.
Также есть два способа. Первый - раздуть макет внутри FrameLayout. Второй - расширить LinearLayout и программно добавить контент. Я покажу вам первый.
public class YourCustomView extends FrameLayout {
public MyView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
inflate(context, R.layout.your_custom_view_layout, this);
}
public MyView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public MyView(Context context) {
this(context, null);
}
public void setContent(int iconRes, int titleRes, String data) {
findViewById(R.id.icon).setDrawableRes(iconRes);
findViewById(R.id.title).setDrawableRes(titleRes);
findViewById(R.id.data).setText(data);
}
}
3. Просто скопируйте и вставьте его :)
Как я вижу, значок и заголовок имеют статус c, и изменяется только содержимое данных, поэтому не стоит повторно использовать такой простой макет, IMO.