0

2番目のアクティビティで番号2が表示されない理由を教えてください


私のメインアクティビティ:

Button bt = (Button) findViewById(R.id.bt);

    bt.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            Intent ii = new Intent(MainActivity.this, Main2Activity.class);


            Bundle b = new Bundle();

            b.putInt("key", 2);

            ii.putExtras(b);

            startActivity(ii);

            finish();
        }
    });



2 番目のアクティビティ:

TextView text = (TextView) findViewById(R.id.text);

    Bundle b = getIntent().getExtras();

    int value = b.getInt("key", 0);

    text.setText(value);


何が悪いのか教えてください...

4

1 に答える 1