tags:

views:

48

answers:

2

I am new to android.I am creating a simple app like puzzle,for that I am cropping a single image into 9 pieces using canvas.Now I need to store these peaces into a single array list,How can I done this.Please help me,thank u in advance.

A: 

The "Hello Views" tutorial has a nice introduction to doing just this. You can see it here in GridView tutorial. There the key code is as follows:

// references to our images
private Integer[] mThumbIds = {
        R.drawable.sample_2, R.drawable.sample_3,
        R.drawable.sample_4, R.drawable.sample_5,
        R.drawable.sample_6, R.drawable.sample_7,
        R.drawable.sample_0, R.drawable.sample_1,
        R.drawable.sample_2, R.drawable.sample_3,
        R.drawable.sample_4, R.drawable.sample_5,
        R.drawable.sample_6, R.drawable.sample_7,
        R.drawable.sample_0, R.drawable.sample_1,
        R.drawable.sample_2, R.drawable.sample_3,
        R.drawable.sample_4, R.drawable.sample_5,
        R.drawable.sample_6, R.drawable.sample_7
};

They're referencing the pictures from the resources folder. Specifically they've chosen to hold them in a "drawable" folder under resources. Does that help?

wheaties
A: 

You can store everything in an ArrayList. A look at the Documentation would have been faster, as this is basica Java knowledge

ArrayList<Bitmap> puzzlePieces = new ArrayList<Bitmap>(9);

puzzlePieces.add(...)
Tseng
i did n't get can u pls post some more explanation or link
MaheshBabu
You save every of your pieces as a Bitmap object, then simply call `puzzlePieces.add(myBitmap)` then get the next piece and repeat until you're done. That's really the most basic Java stuff, it isn't even Android related. When you want to retrive the Bitmaps again simply do `puzzlePieces.get(index)`
Tseng
for(int i =0;i<9;i++){resizedBitmap[i] = Bitmap.createBitmap(bitmapOrg, (i%3)*newWidth, (i/3)*newHeight,newWidth, newHeight);}this my code for this, but i get only boolean values
MaheshBabu