Search code examples
androidandroid-imageviewandroid-gallery

running of out of memory android?


I made custom gallery app with gallery view and image view.its working nice in 4.2 devices,but its getting force closes in 2.3.3

    myHorizontalListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View arg1,
                int position, long id) {
            // if (lastview != null)
            // lastview.setBackgroundColor(0xFFFFFFFF);
            // lastview = arg1;
            // arg1.setBackgroundColor(0xFFFF0000);
            ImageView imageView = (ImageView) findViewById(R.id.image);
            p=position;

            imageView.setBackgroundResource(itemsArray[position]);}}

i think this code caused running out of memory,because every time i am setting new picture under old picture

                 imageView.setBackgroundResource(itemsArray[position])

Solution

  • Reload ur image in imageview in smaller size

    http://developer.android.com/training/displaying-bitmaps/load-bitmap.html