Application crashes at the startup. [closed]

You declared your buttons like this: b1.findViewById(R.id.button1); b2.findViewById(R.id.button2); b3.findViewById(R.id.button3); b4.findViewById(R.id.button4); b5.findViewById(R.id.button5); b6.findViewById(R.id.button6); b7.findViewById(R.id.button7); b8.findViewById(R.id.button8); b9.findViewById(R.id.button9); Replace that with: b1=(Button)findViewById(R.id.button1); And other views (b2,b3.., rez1,rez2..) like that.

How to know which Button was pressed recently among all the Buttons in an activity?

If the Button are in a reusable View like ListView following way will help you. Dynamically set tag to each Button like follow, button1.setTag(“button1”); button2.setTag(“button2”); button3.setTag(“button3″); Then in the onClick method, @Override public void onClick(View v) { Toast.makeText(getApplicationContext(), v.getTag()+” Clicked”, Toast.LENGTH_SHORT).show(); } If Button is in a simple Activity @Override public void onClick(View v) { … Read more