I tried it, thanks for answer, but It doesn't do the expected result.
Here is my code what I tried to do:

public class s extends Activity{

        private static final int REQUEST_CODE = 1;

        ImageView secret;
        public int counter;
        public int counter_foe;
        public TextView txt;
        public TextView counter_txt;
        ImageView pic;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
                // TODO Auto-generated method stub
                super.onCreate(savedInstanceState);
                 this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
                setContentView(R.layout.s);

                counter = 0;
                counter_foe = 0;

                pic = (ImageView) findViewById(R.id.pic);
                final Button next = (Button) findViewById(R.id.next);
                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);

                if (savedInstanceState != null) {
                        counter = savedInstanceState.getInt("counter");
                        counter_foe = savedInstanceState.getInt("counter_foe");
                        counter_txt.setText(String.valueOf(counter));
                        counter_txt_foe.setText(String.valueOf(counter_foe));

                        }

                final 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(String.valueOf(counter_foe));
                                        txt.setText("+1 for Me");
                                }

                                if (rndInt == 1) {
                                        txt.setText("Draw");
                                }

                                if (rndInt == 2) {
                                        counter += 1;
                                        Log.d("improve", "counter improved");
                                        
counter_txt.setText(String.valueOf(counter));
                                        txt.setText("+1 for You");
                                }

                                next.setVisibility(1);
                        }
        };

        final Runnable r2 = new Runnable() {

                @Override
                public void run() {
                        // TODO Auto-generated method stub
                        next.setVisibility(-1);
                }
        };
        next.setOnClickListener(new View.OnClickListener() {


                @Override
                public void onClick(View v) {
                        // TODO Auto-generated method stub
                        Intent i = new Intent("com.z.CHANCES");
                        i.putExtra("counter", counter);
                        i.putExtra("counter_foe", counter_foe);
                        startActivityForResult(i, REQUEST_CODE);
                }

                protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
                        if (resultCode == RESULT_OK && requestCode == 
REQUEST_CODE) {
                                if (data.hasExtra("r")) {
                                        
pic.setBackgroundResource(R.drawable.r1);
                                }
                                else if (data.hasExtra("p")) {
                                        
pic.setBackgroundResource(R.drawable.p2);
                                }
                                else if (data.hasExtra("s")) {
                                        
pic.setBackgroundResource(R.drawable.s1);
                                }
                        }
                }

        });

                secret.postDelayed(r1, 5000);
        }

        @Override
        protected void onSaveInstanceState(Bundle savedInstanceState) {
                // TODO Auto-generated method stub
                savedInstanceState.putInt("counter", counter);
                savedInstanceState.putInt("counter_foe", counter_foe);
                super.onSaveInstanceState(savedInstanceState);
        }
}

I tried it now. I tried with onRestoreInstanceState too, but it looked
like this. I couldn't show my counter and counter_foe content, because
it's everytime shows 0.

Thanks, for any helps.


On aug. 8, 00:16, TreKing <[email protected]> wrote:
> On Sun, Aug 7, 2011 at 3:58 PM, Zwiebel <[email protected]> wrote:
> > So do you think, that if I'm try to do this in the s class, will it
> > be good?:
>
> That is the general idea, yes.
>
> -------------------------------------------------------------------------------------------------
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices

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

Reply via email to