0

私はそのようなレイアウトを持っています:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="horizontal"
          android:layout_width="match_parent"
          android:layout_height="match_parent">

<me.amasawa.studchat.views.MessageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Test"
        android:layout_gravity="center" android:singleLine="false"
        android:autoText="false" android:background="@drawable/text_view_message" android:padding="1dp"
        android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:layout_marginLeft="2dp"/>
<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Это очень длинное сообщение для проверки разметки. Ну как?"
        android:layout_gravity="center"
        android:layout_toRightOf="@+id/textView" android:layout_alignBaseline="@+id/textView"
        android:layout_marginLeft="5dp"/>
</RelativeLayout>

何度も膨らませたい。2番目のTextViewを特定してデータを入力するにはどうすればよいですか? 多分このようなもの:

RelativeLayout tmp = getLayoutInflater().inflate(R.layout.message, null);
TextView tv = (TextView) tmp.findViewByID(...);
tv.setText(data);

ただし、id はすべてのアプリで一意です。この場合、何を使用すればよいですか?

4

3 に答える 3