<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/item_layout" android:weightSum="1"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/item_text" android:layout_weight="0.15" android:text="plain text"/> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <Button style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="1111222" android:id="@+id/Button1" /> <Button style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="111" android:id="@+id/Button2" /> </LinearLayout> </LinearLayout> 

I have such a template, I need to display new elements based on this template, simultaneously setting values ​​for TextView. I also need to hang OnclickListener on the buttons and then change their text, that is, the ArrayAdapter will not help me here.

I did it programmatically, but it's not convenient for me to customize the design.

How to clone this block to have access to its elements?

  • The question is not clear. Describe the problem you are trying to solve, and not your own solution method. Why this template, how and where it should be used, and so. - pavlofff
  • how not to understand? I have a certain block, I need to withdraw such blocks a lot, and then add more - John Doe
  • From what you said, it is advisable to use a fragment with this markup and add it to the activation when required. - pavlofff
  • Well, adding is not a problem, but how to get access to its elements? - John Doe
  • one
    Ask a question about a valid issue. You ask how to display a block with markup, and then say that this is not a problem and in fact you cannot access the elements of this block. Provide the code, like what you do, to reproduce the problem and what does not work. - pavlofff

0