Android: Button setOnClickListener crashed app

darknet

New Member
so i have 2 xml layout files.One is the menu and the other is the app.So now i have some buttons on the one xml file and some other buttons on the other file.So this code works:\[code\] setContentView(R.layout.main); start = (Button) findViewById(R.id.button1); start.setOnClickListener(this);\[/code\]But if i change the view and write this:\[code\] setContentView(R.layout.random); add_person = (Button) findViewById(R.id.add); add_person.setOnClickListener(this); //crash here\[/code\]The app crash!
 
Back
Top