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

Community
  • 1
  • 1
MrJoshFisher
  • 1,143
  • 5
  • 21
  • 48

1 Answers1

-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

Olkunmustafa
  • 3,103
  • 9
  • 42
  • 55