title: Insert layout into another layout
body: <p>i'm struggling with this problem: I want to create a "whatsapp like" list of conversations and i'd like to bundle image, username and last message in a single external layout that I can call programmatically to then add a new one, but for some reason this doesn't work.</p>
  
  <p><strong>chat_link_layout.xml</strong>
  
  </p>
  
  <pre><code>&lt;TextView
      android:text="Username"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:id="@+id/username"
      android:layout_toRightOf="@+id/profileimage"
      android:layout_toEndOf="@+id/profileimage"
      android:textAppearance="@android:style/TextAppearance.Material.Medium"
      android:textColor="@android:color/black"
      android:textStyle="normal|bold"
      android:layout_marginTop="5px"/&gt;
  
  &lt;TextView
      android:text="Last Message"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:id="@+id/lastmessage"
      android:layout_below="@+id/username"
      android:layout_toRightOf="@+id/profileimage"
      android:layout_toEndOf="@+id/profileimage"
      android:textAppearance="@android:style/TextAppearance.Material.Medium"
      android:textColor="@android:color/black" /&gt;
  
  &lt;ImageView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      app:srcCompat="@mipmap/ic_launcher"
      android:layout_alignParentTop="true"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true"
      android:id="@+id/profileimage"
      android:layout_marginRight="10px" /&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>part of the MainActivity.java's onCreate function where i try to call the XML layout</strong></p>
  
  <pre><code>View chatLinkLayout = LayoutInflater.from(getApplication()).inflate(R.layout.chat_link_layout, null);
  
  ConstraintLayout constraintLayout = (ConstraintLayout) findViewById(R.id.content_main);
  constraintLayout.setBackgroundColor(Color.BLACK);
  constraintLayout.addView(chatLinkLayout);
  constraintLayout.addView(new CalendarView(getApplicationContext()));
  </code></pre>
  
  <p>the calendar is shown with no problem.</p>
  
  <p><strong>ChatLinkLayout.java</strong></p>
  
  <pre><code>import android.content.Context;
  import android.widget.FrameLayout;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  public class ChatLinkLayout extends FrameLayout {
  
  private TextView username;
  private TextView lastmessage;
  private ImageView profileimage;
  
  public ChatLinkLayout(Context context) {
  
          super(context);
  
          username = (TextView) findViewById(R.id.username);
          lastmessage = (TextView) findViewById(R.id.lastmessage);
          profileimage = (ImageView) findViewById(R.id.profileimage);
      }
  }
  </code></pre>
  
  <p>Does any of you have any suggestion?</p>
  
  <p>Thank you.</p>