ここではまだ完全な初心者です...
サッカーの試合の仕様 (チーム、時間、トーナメントなど) をレンダリングしようとしています。
team.xml を作成しました。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/teamImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:adjustViewBounds="true"
android:src="@drawable/sofabold_launcher"
android:layout_alignWithParentIfMissing="false"
android:clickable="false"
android:cropToPadding="true"
android:contentDescription="@string/teamLogoContentDescription"/>
<TextView
android:id="@id/teamName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/teamName"
android:textSize="14sp"
android:textStyle="bold"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/teamImageView"/>
</RelativeLayout>
team.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="vertical" >
<include
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/team"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:id="@+id/homeTeam"/>
<include
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/team"
android:layout_below="@id/homeTeam"
android:id="@+id/awayTeam"/>
</RelativeLayout>
そして、teams.xml を含む matchLayout.xml があります。
私の最初の試みは、異なる要素を持つ1つの大きなレイアウトを作成し、それらすべてを私のmatchHolderのIDで参照し、次のようなものを使用してそれらを設定することでした
matchHolder.homeTeamName.setText(match.getHomeTeamName());
populateMatchHolder を次のように変更してみました。
private void populateMatchHolder(View convertView, BaseMatchHolder matchHolder) {
matchHolder.teams = (RelativeLayout) convertView.findViewById(R.id.teams);
}
そして今、別のRelativeLayout(試合)内のRelativeLayout(チーム)内のTextView(ホームチーム名)を参照する方法がわかりません。
ここでポイントを完全に見逃していますか?どこかに homeTeamName という ID が必要ですか? そしてアウェイチーム名?teamName が 2 回あるだけで十分ではありませんか? team.xml の homeTeam インクルードに 1 回、team.xml の awayTeam インクルードに 1 回。
私が何を意味するのかがある程度明確になることを願っています:-) かなり遅く、疲れています:-/
前もって感謝します