【问题标题】:images in Spinner listsSpinner 列表中的图像
【发布时间】:2012-04-07 01:44:14
【问题描述】:

在对https://stackoverflow.com/a/5114475 的响应中,没有提供相应的 XML。我能否获得展示在 Spinners 中插入图像的能力的 XML 文件。

【问题讨论】:

    标签: java android android-xml


    【解决方案1】:

    应该是这样的

    spinner_view.xml

    <?xml version="1.0" encoding="utf-8"?>
    
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="fill_parent"
         android:orientation="horizontal"
         android:layout_height="wrap_content">
    
    
        <TextView 
        android:id="@+id/imageNameSpinner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
    
    
        <ImageView
         android:id="@+id/xR.id.imageIconSpinner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
    
     </LinearLayout>
    

    list_editoradd_dialog.xml //这是最低限度的

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    
    
        <Spinner
        android:id="@+id/spinnerAddImageList"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
    
    
    </LinearLayout>
    

    【讨论】:

    • R.layout.list_editoradd_dialog 和 R.layout.spinner_view 的 XML 怎么样?谢谢。
    • 我最初给的是spinner_view。我应该给它贴上标签。刚刚添加了 list_editoradd_dialog.xml
    • 你能让这个例子真正执行显示 Spinner 吗?我仍然在语法和执行期间遇到问题(当我更改语法以允许执行时)。例如,我必须将整数转换添加到语句中: ((ImageView) convertView.findViewById(R.id.imageIconSpinner)).setBackgroundResource((Integer) dataRecieved.get(position).get("Icon"));谢谢你的帮助。迈克
    • 我认为该代码是一个完整的示例。您遇到了什么样的错误?
    • 我在 spinnerList.add(map);声明:方法 add(capture#3-of ? extends Map) 在类型 List> 不适用于参数(HashMap)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-26
    • 2011-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-07
    相关资源
    最近更新 更多