Java 如何将pdf缩略图设置为自定义适配器列表视图的图像视图?

Java 如何将pdf缩略图设置为自定义适配器列表视图的图像视图?,java,android,bitmap,Java,Android,Bitmap,我的代码大部分工作正常。我不知道如何将文件预览位图图像传递到构造函数中。如何将位图图像设置到自定义ListView适配器的图像视图中 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_every_day__file_explorer); fileNameLis

我的代码大部分工作正常。我不知道如何将文件预览位图图像传递到构造函数中。如何将位图图像设置到自定义
ListView
适配器的图像视图中

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_every_day__file_explorer);

    fileNameList=(ArrayList<File_Explorer>)getLastNonConfigurationInstance();

    if(fileNameList==null) {

        ListView lv = (ListView)findViewById(R.id.listView);
        lv.setItemsCanFocus(false);
        lv.setChoiceMode(lv.CHOICE_MODE_MULTIPLE);
        fileNameList = new ArrayList<File_Explorer>();
        arrayAdapter = new ArrayAdapter<File_Explorer>(this,
                android.R.layout.simple_list_item_1, fileNameList);

        lv.setAdapter(arrayAdapter);

        File file =new File(Environment.getExternalStorageDirectory().getAbsolutePath(),"Every_Day");
        list = file.listFiles();
        byte[] bytes;
        try {
            FileInputStream is = new FileInputStream(file);

            // Get the size of the file
            long length = file.length();
            bytes = new byte[(int) length];
            int offset = 0;
            int numRead = 0;
            while (offset < bytes.length && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
                offset += numRead;
            }
            ByteBuffer buffer = ByteBuffer.NEW(bytes);
            String data = Base64.encodeToString(bytes, Base64.DEFAULT);
            PDFFile pdf_file = new PDFFile(buffer);
            PDFPage page = pdf_file.getPage(2, true);

            RectF rect = new RectF(0, 0, (int) page.getBBox().width(),
                    (int) page.getBBox().height());

            Bitmap image = page.getImage((int)rect.width(), (int)rect.height(), rect);
            FileOutputStream os = new FileOutputStream("/storage/extSdCard/pdf.jpg");
            image.compress(Bitmap.CompressFormat.PNG, 80, os);
             ImageView i = ((ImageView) findViewById(R.id.fileimage));
            BitmapDrawable ob = new BitmapDrawable(getResources(), image);
            i.setBackgroundDrawable(ob);

            if(list!=null) {
                for (int i = 0; i < list.length; i++) {
                    // *** problem below -- how to pass the image to File_Explorer? 
                    fileNameList.add(new File_Explorer(list[i].getName(),???));

                }
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        arrayList = new ArrayList<File_Explorer>();
        arrayList.addAll(fileNameList);
        arrayAdapter = new FileExplorerArrayAdapter(this,arrayList);
        lv.setAdapter(arrayAdapter);
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                String file = list[(int)id].getName();
                openPdfIntent(file);
            }
        });
    }
}
}
@覆盖
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u每天\u文件\u浏览器);
fileNameList=(ArrayList)getLastNonConfigurationInstance();
if(fileNameList==null){
ListView lv=(ListView)findViewById(R.id.ListView);
lv.setItemsCanFocus(假);
lv.setChoiceMode(lv.CHOICE\u MODE\u MULTIPLE);
fileNameList=newarraylist();
arrayAdapter=新的arrayAdapter(此,
android.R.layout.simple_list_item_1,fileNameList);
低压设置适配器(阵列适配器);
File File=新文件(Environment.getExternalStorageDirectory().getAbsolutePath(),“每天”);
list=file.listFiles();
字节[]字节;
试一试{
FileInputStream is=新的FileInputStream(文件);
//获取文件的大小
long length=file.length();
字节=新字节[(int)长度];
整数偏移=0;
int numRead=0;
而(偏移量=0){
偏移量+=numRead;
}
ByteBuffer缓冲区=ByteBuffer.NEW(字节);
字符串数据=Base64.encodeToString(字节,Base64.DEFAULT);
PDFFile pdf_file=新的PDFFile(缓冲区);
PDFPage page=pdf_file.getPage(2,true);
RectF rect=new RectF(0,0,(int)page.getBBox().width(),
(int)page.getBBox().height());
位图图像=page.getImage((int)rect.width(),(int)rect.height(),rect);
FileOutputStream os=新的FileOutputStream(“/storage/extSdCard/pdf.jpg”);
image.compress(Bitmap.CompressFormat.PNG,80,os);
ImageView i=((ImageView)findViewById(R.id.fileimage));
BitmapDrawable ob=新的BitmapDrawable(getResources(),image);
i、 可缩位拉深(ob);
如果(列表!=null){
for(int i=0;i
试图澄清问题我只是想知道如何将位图图像设置到自定义适配器的图像视图中。问题是图像视图仅适用于整数。