0

在我的应用程序中,我在表格布局的表格行中动态设置 imageview textview。但我无法设置 imageview。我试过了。它的 olny 显示 textview 而不是 imageview。我如何设置图像视图。请帮我。下面是代码-

 Bitmap b=ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile((file.getPath()+".jpeg")), 50,50);

            im=new ImageView(this);
            im.setImageBitmap(b);
            im.setLayoutParams(new LayoutParams(50,50));


            nameoffile=new TextView(this);
            nameoffile.setText(myfile);
            nameoffile.setWidth(200);

            sizeoffile=new TextView(this);
            sizeoffile.setText(size+"KB");
            sizeoffile.setWidth(100);

            tr=new TableRow(this);
            tr.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
            tr.addView(im);
            tr.addView(nameoffile);
            tr.addView(sizeoffile);
            tl.addView(tr,new TableLayout.LayoutParams(
                    LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
4

1 回答 1

0

尝试

im.setImageResource(b);

代替

im.setImageBitmap(b);
于 2013-02-14T17:25:56.090 回答