-1

all Im getting the error java.lang.outofmemoryerror BitmapFactory error and I need some help on fixing it and this is the best option I have, i know that you can scale the images to stop them from using too much memory but not quite sure how to go about it with the code I have.

public class MainActivity extends Activity {
ListView list;
  String[] web = {
          //77 Images
  } ;
  Integer[] imageId = {
          //77 Images
  };
@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    PositionList adapter = new
            PositionList(MainActivity.this, web, imageId);
    list=(ListView)findViewById(R.id.list);
        list.setAdapter(adapter);
        list.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {

                if(position == 0) {
                    //code specific to first list item    
                    Intent myIntent = new Intent(view.getContext(), Position0.class);
                    startActivityForResult(myIntent, 0);
                }

        -------------------Repeats--------------------------

               if(position == 77) {
                    //code specific to first list item    
                    Intent myIntent = new Intent(view.getContext(), Position77.class);
                    startActivityForResult(myIntent, 0);
                }

I tried using the examples from here but no luck implementing them - ImageAdapter and ListView (java.lang.OutOfMemoryError: bitmap size exceeds VM budget)

4
  • bitmap is too big, recreating many of them its pretty much bigger biggest.. resize/crop your images.. Commented Oct 25, 2014 at 15:49
  • Wouldn't that mean keeping a thumbnail image and a high res image ? Commented Oct 25, 2014 at 16:05
  • Use picasso library, its free and it's easy to use Commented Oct 25, 2014 at 16:21
  • no it means get ur image from its source and resize it before you bring it to the listview to use it..triming ur images to android reasonable size helps keep ur app responsive.. 400 *400 Commented Oct 26, 2014 at 21:30

1 Answer 1

-2

I had a a same problem. You can use picasso or Universal Image Loader. I suggest to Universal Image Loader. Picasso has some problems.

https://github.com/nostra13/Android-Universal-Image-Loader

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.