如何在listview小部件中放置图像?

时间:2014-10-29 04:59:31

标签: android listview android-listview

嘿所以我尝试了一些教程,但到目前为止还没有找到我的问题。所以我试图在listview小部件上放置一些图像。但是,我只使用图像作为横幅,我几乎试图制作一个可滚动的图片列表,宣传“特价”。因此,当我尝试创建一个数组时,我被鼓励在我的数组中使用int类型。如果是这样,我如何将这些整数值作为图像资源文件夹中的图像合并?到目前为止,到目前为止,我已经陷入困境,所以至少有一些代码:

package com.demoapp.oscar.redmoon;

import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;

import java.util.ResourceBundle;

public class specials extends Activity{
    @Override
    protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);

    setContentView(R.layout.specials);

    String[] specialImages;
    ListView specialList;

    Integer[] images = {R.drawable.freeDrink, R.drawable.HappyHour,
            R.drawable.munchieMondays,R.drawable.whackyWed};

    ListAdapter theAdapter = new ArrayAdapter<Integer>(this, android.R.layout.simple_list_item_1
            ,images);

    specialList = (ListView)findViewById(R.id.specials_list);

    specialList.setAdapter(theAdapter);
}

}

任何帮助将不胜感激!

0 个答案:

没有答案
相关问题