
Untitled
By: a guest on
Apr 25th, 2012 | syntax:
None | size: 0.63 KB | hits: 7 | expires: Never
Invoke routine in class from other class (not activity) in JAVA for Android
public static void addFruit(MainGamePanel context){
fruitInventory();
//add 10 apples with random coordinates
for (int i = 0; i < 10; i++) {
Random Rnd = new Random();
apple nextApple = new apple(BitmapFactory.decodeResource(context.getResources(),
fruitResources.get(Rnd.nextInt(fruitResources.size()))));
//add them to the arraylist
MainGamePanel.AppleList.add(nextApple);
}
public class Button{
private Context context;
public Button(Context context)
{
this.context = context;
}
....
fruitmanager.addfruit(context);
...
new Button(this);