无法查看单选按钮的值

时间:2014-09-28 23:51:32

标签: java android

它没有显示任何错误,但是当我在手机上运行时,应用程序每次都会崩溃!

`PizzaType.java

protected void onCreate(Bundle savedInstanceState) {    
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pizzatype);
    RadioButton rButton = (RadioButton) findViewById(R.id.radioButton);
    String rText = rButton.getText().toString();
    Intent intent = new Intent(Pizzatype.this, Overview.class);
    intent.putExtra("Bbread","Brown Bread");
    startActivity(intent);
    String data = getIntent().getExtras().getString("Bbread");
}

Overview.java

protected void onCreate(Bundle savedInstanceState) {    
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_overview);
    String value= getIntent().getStringExtra("Bbread");
    Intent intent = new Intent(this, Pizzatype.class);
    intent.putExtra("Bbread", value);
    startActivity(intent);
    String data= getIntent().getStringExtra("Bbread");
}

1 个答案:

答案 0 :(得分:0)

尝试清理并重新运行项目。有时候R.java文件被破坏了。它会导致空指针异常。