2013-02-14 20 views
0

我在表格布局的表格行中动态设置imageview文本视图。 但我无法设置imageview.i尝试it.its olny显示textview不Imageview。我如何设置imageview。 请帮助我。下面 是代码 -在我的应用程序中动态设置图像视图在桌面布局android

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)); 

回答

0

尝试

im.setImageResource(b); 

,而不是

im.setImageBitmap(b); 
相关问题