android - Display the grid view images according to a number -
Hi I want to display the number of images according to a number. This means that if the number is 1 then I want to hate only one image in the grid, if the number is 3 then I want to display 3 images in the grid. But I only take the same image which means that the image will be displayed on the basis of that picture
< P> I think you mean this:
// Images are located in res, a page and so on in the res / DRIBLE folder private integer IMG (integer val) {if ( Val == 0) Returns R.drawable.zero; Else if (val == 1) R.drawable.one; Else if (val == 2) returns R.drawable.two; Else if (val == 3) R.drawable.three; Else if (val == 4) returns R.drawable.four; Otherwise, return (Val == 5) R.drawable.five; Else if (val == 6) returns R.drawable.six; Else if (val == 7) returns R.drawable.Sseven; Else if (val == 8) Return to R.drawable.eight; And returned R.drawable.nine; }
... and call this method using this statement:
// "3" to a variable named img1.setImageResource Should be replaced with (getImg (3));
IMG1 is an imageview variable.
Comments
Post a Comment