0

こんにちはアクティビティを最初に開始すると正常に動作しますが、再度開始すると、ビットマップサイズがVMバジェットを超えます

私のコードは以下です

public class TemplateList extends BaseActivity {

ImageUtil imgUtil;
private GridView gridView;
private LinearLayout layoutInflate;
private String Url;
public ArrayList<ArrayList<picitem>> data;
public ImageLoader1 imageLoader;
AlertMessages messages;

private ProgressDialog pd;
Thread thread = null;
private Handler handler = new Handler() {
    public void handleMessage(Message msg) {
        if (pd != null)
            pd.dismiss();
        if (msg.what == 11) {
            try {
                fillList();
            } catch (Exception e) {
                Toast.makeText(TemplateList.this, "An error has occured", Toast.LENGTH_LONG).show();
            }
        } else if (msg.what == 0) {

        } else if (msg.what == 1) {

        } else if (msg.what == 25) {

        } else {
            messages.showNetworkAlert();
        }
    }
};

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

    btnHome = (Button) findViewById(R.id.btnHome);
    btnPostGard = (Button) findViewById(R.id.btnPostGard);
    btnDrake = (Button) findViewById(R.id.btnDrake);
    btnFacebook = (Button) findViewById(R.id.btnFacebook);

    gridView = (GridView) findViewById(R.id.gridFrame);

    btnHome.setBackgroundResource(R.drawable.home);
    btnPostGard.setBackgroundResource(R.drawable.postcardup);
    btnDrake.setBackgroundResource(R.drawable.drake);
    btnFacebook.setBackgroundResource(R.drawable.facebbook);

    imgUtil = new ImageUtil();
    messages = new AlertMessages(this);
    layoutInflate = (LinearLayout) findViewById(R.id.layoutinflate);

    imageLoader = new ImageLoader1(getApplicationContext(), Url);

    data = new ArrayList<ArrayList<picitem>>();
    fillData();
}

private void fillList() {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    for (int i = 0; i < data.size(); i++) {

        View customView = inflater.inflate(R.layout.cutomviewhorizontal, null);
        LinearLayout layoutHorizontalScroll = (LinearLayout) customView.findViewById(R.id.customhoriview);
        TextView txtCategory = (TextView) customView.findViewById(R.id.txtCategoryInflate);
        System.out.println();
        txtCategory.setText(data.get(i).get(0).getCategoryName()+" Templete");
        ArrayList<picitem> items = data.get(i);         
        for (int j = 0; j < items.size(); j++) {
            View customView1 = inflater.inflate(R.layout.imginflate, null);
            final ImageView img = (ImageView) customView1.findViewById(R.id.imgCategoryInflate);
            img.setTag(items.get(j).getThumbImagePath().toString().trim());
            final String imagepathString=items.get(j).getImagePath().toString().trim();
            imageLoader.DisplayImage(items.get(j).getThumbImagePath().toString().trim(), this, img);

            img.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent i = new Intent(TemplateList.this, PictureEditor.class);
                    Bundle b = new Bundle();
                    b.putString("Key", "2");
                    b.putString("Index", imagepathString);
                    i.putExtras(b);
                    v.getContext().startActivity(i);
                    finish();
                }
            });

            layoutHorizontalScroll.addView(customView1);
        }

        layoutInflate.addView(customView);
        }
}

private void fillData() {
    if (Utils.isOnline(TemplateList.this)) {

        pd = ProgressDialog.show(TemplateList.this, "", "Loading...", true, false);
        new Thread(new Runnable() {

            @Override
            public void run() {
                try {
                    Parsing p = new Parsing();
                    data = p.getList();
                    handler.sendEmptyMessage(11);
                } catch (Exception e) {
                    e.printStackTrace();
                    handler.sendEmptyMessage(0);
                }
            }
        }).start();
    } else {
        messages.showNetworkAlert();
    }
}

@Override
protected void onResume() {
    super.onResume();
    startClick();
}

}

私のLogcatは下にあります

   12-19 16:30:52.069: E/AndroidRuntime(11442): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
   12-19 16:30:52.069: E/AndroidRuntime(11442):     at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
   12-19 16:30:52.069: E/AndroidRuntime(11442):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:470)
  12-19 16:30:52.069: E/AndroidRuntime(11442):  at com.redwood.ImageLoader1.decodeFile(ImageLoader1.java:145)
   12-19 16:30:52.069: E/AndroidRuntime(11442):     at com.redwood.ImageLoader1.getBitmap(ImageLoader1.java:103)
  12-19 16:30:52.069: E/AndroidRuntime(11442):  at com.redwood.ImageLoader1.access$0(ImageLoader1.java:96)
  12-19 16:30:52.069: E/AndroidRuntime(11442):  at com.redwood.ImageLoader1$PhotosLoader.run(ImageLoader1.java:200)
4

0 に答える 0