So I am making an app that has over 200 sunset pictures (taken by myself:P). I want to display them all via android.R.layout.simple_gallery_item
I tried tossing them all in the drawable folder, then bitmapping each one and drawing it on the screen, but I get an Out of memory error.
What would be the best way to store these jpg?
The only two ways I can think of are:
(PS: If can't tell, I am new to Android Developing)
Thanks!
Code:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
System.out.println("Noobs");
ArrayList<Image> img = new ArrayList<Image>();
for (int i=1; i<3; i++) {
int imageResource = getResources().getIdentifier("@drawable/bm" + String.valueOf(i), null, getPackageName());
img.add(ImageView.setImageResource(imageResource));
System.out.println("Did Pic "+String.valueOf(i));
}
System.out.println("Come so far!");
ListAdapter picAdapt = new ArrayAdapter<Image>(this, android.R.layout.simple_gallery_item, img);
ListView picListView = (ListView) findViewById(R.id.gallery);
picListView.setAdapter(picAdapt);
} }
I recommend you use picasso http://square.github.io/picasso/
or glide https://github.com/bumptech/glide
those two help you to get and optimize your images