I'm working on a program that generates dice, lots of dice. I finally
found out how to make an adapter to display an image dynamically, but
now I have a new problem. The dice that are generated/displayed by the
Adapter change if they scroll off the screen. Basically every time
each die image moves into view it is re-randomizing what die it needs
to show. I also need it to log the die results to a separate file, but
I don't know where to stick that code, seeing as it would add dice to
the list every time a die is re-drawn.

This is my current code:

public View getView(int position, View convertView, ViewGroup parent)
{
        ImageView imageView;
        if (convertView == null) {
            imageView = new ImageView(mContext);
            imageView.setLayoutParams(new GridView.LayoutParams(75,
75));
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            imageView.setPadding(1, 1, 1, 1);

        } else {
            imageView = (ImageView) convertView;

        }


                Random RollDie = new Random();
            Die1 = RollDie.nextInt(6);
            Die1Copy = Die1;
            if(((Die1Copy += QuickShoot.BSFinal) < 6)) {
                Die1 += 6;
            }

                imageView.setImageResource(DieResult[Die1]);

                return imageView;

        }



    // references to our images
        private Integer[] DieResult = {
            R.drawable.die1, R.drawable.die2,
            R.drawable.die3, R.drawable.die4,
            R.drawable.die5, R.drawable.die6,
            R.drawable.die1under, R.drawable.die2under,
            R.drawable.die3under, R.drawable.die4under,
            R.drawable.die5under, R.drawable.die6under

    };



}


If anyone knows how I can make it generate a Die for a set position
and then not redraw please let me know you will save my life!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to