Answer the question
In order to leave comments, you need to log in
How to correctly display messages in such a layout?
There is such a layout. How to display messages in it?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:paddingRight="20dip"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="left"
android:background="@drawable/bubble_yellow">
<RelativeLayout
android:id="@+id/nicknameAndTimeWrapper"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/nick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:textStyle="bold"
android:text="Shyro:"
android:layout_margin="1dip"
android:paddingLeft="1dip"
android:textColor="@android:color/primary_text_light" />
</RelativeLayout>
<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_margin="1dip"
android:paddingLeft="1dip"
android:text="Hello bubbles"
android:textColor="@android:color/primary_text_light" />
</LinearLayout>
</LinearLayout>
Answer the question
In order to leave comments, you need to log in
Layout-wise, the outer LinearLayout and inner RelativeLayout look redundant. What is the meaning of their existence?
As to your question, it's not clear to me. Search for the desired TextView by parent with findViewById, then set the text with setText :
parent.findViewById(R.id.message).setText("new message");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question