【问题标题】:How to set images for all list items如何为所有列表项设置图像
【发布时间】:2017-10-05 16:18:17
【问题描述】:

我不知道如何在本教程链接中为同一图像中的所有列表视图项设置图像:https://www.codeproject.com/Articles/507651/Customized-Android-ListView-with-Image-and-Text 如果我将雪中的 xml 数据源更改为我的默认图像,它不会出现在输出空白显示中,所以我需要编码部分在哪里进行了更改以设置一张图像的所有列表

【问题讨论】:

    标签: java android xml eclipse listview


    【解决方案1】:

    在 BinderDataClass 中删除以下代码:

    String uri = "drawable/"+ weatherDataCollection.get(position).get(KEY_ICON); 
    int imageResource = vi.getContext().getApplicationContext().getResources().getIdentifier( uri, null, vi.getContext().getApplicationContext().getPackageName()); 
    Drawable image = vi.getContext().getResources().getDrawable(imageResource); holder.tvWeatherImage.setImageDrawable(image);
    

    如果要更改默认显示的图像,可以在名为 list_row.xml 的列表项 xml 文件中定义更改 ImageView 的 src 属性

        <ImageView
    
            android:id="@+id/list_image"
    
            android:contentDescription="@string/app_name"
    
            android:layout_width="60dip"
    
            android:layout_height="60dip"
    
            android:src="@drawable/sunny" />
    

    【讨论】:

      猜你喜欢
      • 2015-01-06
      • 2013-06-07
      • 1970-01-01
      • 1970-01-01
      • 2017-09-05
      • 2012-08-15
      • 1970-01-01
      • 2011-08-26
      • 1970-01-01
      相关资源
      最近更新 更多