android - 如何像自定义 ListView 一样创建自定义 ImageView ?

标签 android listview imageview custom-lists

我想制作一个包含多项选择题的应用程序。每个问题都有三个选项。我想用一张背景图片显示该选项。并且还想为每个问题随机更改该图像的颜色。我怎样才能做到这一点?

是否可以通过为每一行放置不同的背景图像来创建 ListView ?

结果.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>

最佳答案

It is possible to create list view by putting differnt background image for each row?

是的。看看articles on the internet支持带有自定义适配器和自定义 View 的 ListView 。这是通过 getView() 方法完成的,并且不乏示例/教程。

关于android - 如何像自定义 ListView 一样创建自定义 ImageView ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15697642/

相关文章:

带 fragment 的 Android ListView

java - ImageView 变化不够快

android - ViewFlipper 图像未被查看

android - AOSP构建错误

android - 如何在 Android 的 CameraManager 中注销可用性回调

安卓 : AutoCompleteTextView listview scroll listener (for endless scrolling)

android - ListView NullpointerException 问题

imageview - 如何将 imageView 添加到 javafx 区域元素?

java - @SuppressWarnings ("deprecation") 和 ("unused") 在 Java 中是什么意思?

android - 使用 xml 从 rss 提要中获取数据,然后存储在 ArrayList 中