also, once you change the bitmap, you need to call invalidate() so
onDraw is called again

On Aug 6, 4:41 pm, Zwiebel <hunzwie...@gmail.com> wrote:
> Thanks I will try it!
>
> On aug. 6, 20:04, Kostya Vasilyev <kmans...@gmail.com> wrote:
>
>
>
>
>
>
>
> > You are calling TextView.setText(int)
>
> > counter_txt_foe.setText(counter_foe);
>
> > which expects an R.string resource ID for the text.
>
> > Do this instead:
>
> > counter_txt_foe.setText(String.valueOf(counter_foe));
>
> > to call TextView.setText(CharSequence)
>
> > -- Kostya
>
> > 07.08.2011 0:01, Zwiebel пишет:
>
> > > Thanks, I could make it with your helps. But now I'm found a new
> > > problem. I try to modify my textview with .setText method, but I got
> > > this error:
>
> > > ERROR/AndroidRuntime(3745): android.content.res.Resources
> > > $NotFoundException: String resource ID #0x1
> > > ERROR/AndroidRuntime(3745):     at
> > > android.content.res.Resources.getText(Resources.java:222)
> > > ERROR/AndroidRuntime(3745):     at
> > > android.widget.TextView.setText(TextView.java:3011)
>
> > > My source:
>
> > > public class sc extends Activity{
>
> > >    ImageView secret;
> > >    public int counter;
> > >    public int counter_foe;
> > >    public TextView txt;
> > >    public TextView counter_txt;
> > >    @Override
> > >    protected void onCreate(Bundle savedInstanceState) {
> > >            // TODO Auto-generated method stub
> > >            super.onCreate(savedInstanceState);
> > >            setContentView(R.layout.sc);
>
> > >            counter = 0;
> > >            counter_foe = 0;
>
> > >            txt = (TextView) findViewById(R.id.txt);
> > >            secret = (ImageView) findViewById(R.id.secret);
> > >            counter_txt = (TextView) findViewById(R.id.counter_me);
> > >            final TextView counter_txt_foe = (TextView)
> > > findViewById(R.id.counter_me_foe);
>
> > >            Random rand = new Random();
> > >            int rndInt = rand.nextInt(3) + 1;
>
> > >            Runnable r1 = new Runnable() {
>
> > >                    @Override
> > >                    public void run() {
> > >                            // TODO Auto-generated method stub
> > >                            int imageArr[] = new int[3];
>
> > >                            imageArr[0] = R.drawable.r1_mirror;
> > >                            imageArr[1] = R.drawable.s1_mirror;
> > >                            imageArr[2] = R.drawable.p2_mirror;
>
> > >                            Random rand = new Random();
> > >                            int rndInt = rand.nextInt(3);
>
> > >                            secret.setImageResource(imageArr[rndInt]);
>
> > >                            if (rndInt == 0) {
> > >                                    counter_foe += 1;
> > >                                    Log.d("improve", "counter_foe 
> > > improved");
> > >                                    counter_txt_foe.setText(counter_foe);
> > >                            }
>
> > >                    }
> > >    };
>
> > >            secret.postDelayed(r1, 5000);
> > >    }
>
> > > }
>
> > > Thanks for any helps.
>
> > > On aug. 6, 19:46, Nikolay Elenkov<nikolay.elen...@gmail.com>  wrote:
> > >> On Sun, Aug 7, 2011 at 2:38 AM, Zwiebel<hunzwie...@gmail.com>  wrote:
> > >>> I tried it out and sadly n is 0 everytime, but I don't know why.
> > >> Reading the docs usually helps:
>
> > >> public static double random()
>
> > >>      Returns a double value with a positive sign, greater than or equal
> > >> to 0.0 and less than 1.0.
>
> > >> You are casting to int, so it's always going to be zero. What you need is
> > >> java.util.Random.nextInt().
>
> > --
> > Kostya Vasilyev

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to