@akass
Developer

Как правильно выводить сообщения в такой layout?

Есть такой layout. Как в него выводить сообщения?a8b54282d36c45708a8b1bc51911c80b.JPG
<?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>
  • Вопрос задан
  • 532 просмотра
Решения вопроса 1
@swba
Web => Mobile
По вёрстке: внешний LinearLayout и внутренний RelativeLayout выглядят излишними. В чём смысл их существования?

По сути вашего вопроса: мне суть не очень ясна. Ищете нужный TextView по родителю с помощью findViewById, потом устанавливаете текст с помощью setText:

parent.findViewById(R.id.message).setText("new message");
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы