为什么imageview在android中加载多个图像时占用空间

时间:2012-05-25 08:30:24

标签: android android-imageview

当我加载图像时,图像占用空间我不知道为什么在第一次显示其他图像后才占用空间是什么问题通常你可以看到我的活动java类有imagedisplay方法我在这里加载图像图像在第一张图像之前和之后占用空间

enter image description here

  

myactivity.java

public void imagedisplay()
{
    itable = (TableLayout)findViewById(R.id.itable);

    String chekplace=null;

    Log.e("MyList Size", "Counted--->"+mylist.size());

    int size=mylist.size();
    s:
       for(int j=0;j<mylist.size();j++)
        {

            trstate = new TableRow(this);
            trstate.setGravity(Gravity.CENTER_HORIZONTAL);


            tstate = new TextView(this);
            tstate.setGravity(Gravity.CENTER);

            String tempstate = mylist.get(j).get(KEY_PLACENAME).intern().toString();
            tstate.setText(tempstate);

            trstate.addView(tstate);
            itable.addView(trstate);

            chekplacename=mylist.get(j).get(KEY_PLACENAME).intern().toString();


            int counter=1;
            String nextplace=chekplacename;
            chekplace=nextplace;
            m:
                while(nextplace==chekplace)
            {
                     trimage = new TableRow(this);
             trimage.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
              for (int m = 1; m <= 4; m++)
           {                      
                       chekplace=mylist.get(j).get(KEY_PLACENAME).intern().toString();

                if(nextplace==chekplace)     
                {
                          iimage = new ImageView(this);
              iimage.setPadding(2,2,2,2);
                          BitmapFactory.Options bmOptions;
              bmOptions = new BitmapFactory.Options();
             bmOptions.inSampleSize = 4;
                String loadimageurl=mylist.get(j).get(KEY_PHOTOURL).intern().toString();
                counter++
                        bm = LoadImage(loadimageurl, bmOptions);

                int height=bm.getWidth();
                int width=bm.getHeight();  

               Log.e("newheight","Before--->" +height);
           Log.e("new width","Before--->"+width);
               bm=resize(bm, bm.getHeight(), bm.getWidth());
               height=bm.getWidth();
               width=bm.getHeight(); 

                    iimage.setLayoutParams(new TableRow.LayoutParams( height, width));
        iimage.setImageBitmap(bm);
                trimage.addView(iimage); 
                     }

           }
            itable.addView(trimage);    

        }    
     }       

0 个答案:

没有答案