Android App Crashes on Button Click

前端 未结 4 370
野性不改
野性不改 2021-01-26 05:54

I have been attempting to make my first android application (a simple temperature converter) in Eclipse, but when I click the button on my phone the app crashes. Here is the ful

4条回答
  •  不知归路
    2021-01-26 06:33

    You need to tell the click listener to listen to a particular button. So, in other words set an OnItemClickListener on the button. Something as follows:

    Button button = (Button) findViewById(R.id.button1);
    button.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        // do the "on click" action here
      }
    });
    

    Hope this helps. If not, then please comment with further issue.

提交回复
热议问题