我想使許多xml佈局的Android應用程序,但我在這裏遇到問題。 該問題從第二個按鈕開始,然後應用程序崩潰。不能使用更多然後2佈局
public class MonkeyQuest_androidActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button newGame = (Button) findViewById(R.id.newGame);
newGame.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setContentView(R.layout.name);
final Button setName= (Button) findViewById(R.id.setName);
setName.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setContentView(R.layout.Menu);
}
});
}
});
}
}
你是什麼意思,「許多XML佈局」?你的意思是你需要很多活動嗎?它看起來像你試圖多次更改一個活動的佈局?你是什麼意思「問題從第二個按鈕開始」?什麼第二個按鈕?你是否遇到異常?什麼是例外?請發佈logcat(只有相關位)以及更多關於您想要實現的內容以及爲什麼。 – Simon 2012-02-07 20:12:00