1

多肢選択問題を含むアプリケーションを 1 つ作成したいと考えています。各質問には 3 つの選択肢があります。そのオプションを 1 つの背景画像で示したいと思います。また、質問ごとにその画像の色をランダムに変更したいと考えています。どうやってやるの?

行ごとに異なる背景画像を配置してリスト ビューを作成することはできますか?

結果.xml

<LinearLayout
     android:id="@+id/linearlayoutans"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentBottom="true"
     android:layout_marginBottom="30dp"
     android:layout_toLeftOf="@+id/chrono"
     android:orientation="horizontal" >

     <TextView
         android:id="@+id/txt_ans_true"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_margin="10dp"
         android:background="@drawable/ic_launcher"
         android:gravity="center"
         android:textColor="#000000" />

     <TextView
         android:id="@+id/txt_ans_1"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_margin="10dp"
         android:background="@drawable/ic_launcher"
         android:gravity="center"
         android:textColor="#000000" />

     <TextView
         android:id="@+id/txt_ans_2"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_margin="10dp"
         android:background="@drawable/ic_launcher"
         android:gravity="center"
         android:textColor="#000000" />
 </LinearLayout>
4

1 に答える 1

2

行ごとに異なる背景画像を配置してリスト ビューを作成することはできますか?

はい。カスタム アダプターとカスタム ビューを使用してリストビューをサポートしているインターネット上の記事を見てください。これはgetView()メソッドから行われ、例やチュートリアルが不足することはありません。

于 2013-03-29T05:17:33.357 に答える