它没有显示任何错误,但是当我在手机上运行时,应用程序每次都会崩溃!
`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");
}
答案 0 :(得分:0)
尝试清理并重新运行项目。有时候R.java文件被破坏了。它会导致空指针异常。