Random Images in program

General topics about the Android-Platform itself.
Coding issues please to the subforum right below.

Random Images in program

Postby Sheena21 » Sat Mar 07, 2009 3:27 pm

Hi Evrybody ,



now i am Developing one Game on Card .
in that how can i take random images everyTime .
email id====> mca.dax.dax@gamil.com
Sheena21
Freshman
Freshman
 
Posts: 5
Joined: Wed Jan 21, 2009 8:54 am

Top

Re: Random Images in program

Postby sarangkulkarni17 » Mon Mar 09, 2009 11:12 am

Sheena21 wrote:Hi Evrybody ,



now i am Developing one Game on Card .
in that how can i take random images everyTime .



Use Random class of java

Random random = new java.util.Random();
random.nextInt()
sarangkulkarni17
Developer
Developer
 
Posts: 29
Joined: Fri Feb 13, 2009 10:00 am
Location: Pune

Re: Random Images in program

Postby Sheena21 » Mon Mar 09, 2009 2:26 pm

[quote="sarangkulkarni17"][quote="Sheena21"]Hi Evrybody ,









Thank U For Giving Me Reply

Actually i am Using that Class But How Can I take Images if u Don't Mind Send Me A Only Two/Three Images are Selected Random EveryTime Sample Code.



PlZZZZZZZZZZZZZZZZ.........I Hope that U Will Help Me
email id====> mca.dax.dax@gamil.com
Sheena21
Freshman
Freshman
 
Posts: 5
Joined: Wed Jan 21, 2009 8:54 am

Re: Random Images in program

Postby sarangkulkarni17 » Tue Mar 10, 2009 6:18 am

i dont know much about that.
but try this

public int getRandomInt(int r)
{
return ((random.nextInt() >>> 1) % r);
}

imageNo=getRandomInt(totalNoOfImages);

suppose u hav totalNoOfImages=10 then it will giv no in betn 0 to 9

depending on that u can put it in switch case where u are drawing bitmaps.
this will give one image no. at a time if u want 2 or 3 then use whole logic including switch in for loop
or store no in array and call that drawing function in for loop
sarangkulkarni17
Developer
Developer
 
Posts: 29
Joined: Fri Feb 13, 2009 10:00 am
Location: Pune

Re: Random Images in program

Postby Sheena21 » Tue Mar 10, 2009 7:45 am

Thank u SarangKulkarni for Sending Me Reply
email id====> mca.dax.dax@gamil.com
Sheena21
Freshman
Freshman
 
Posts: 5
Joined: Wed Jan 21, 2009 8:54 am

Top

Return to General

Who is online

Users browsing this forum: No registered users and 2 guests