title: Is this the correct way to implement 'setOnClickListener()'?
body: <pre><code>##For accepting a string from a EditText on clicking a button##
  
  @Override
  public void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      //save button
      //be notified when the button is clicked
      saves=(Button)findViewById(R.id.save);
      saves.setOnClickListener(onSave);
  }
  private View.OnClickListener onSave=new View.OnClickListener()
  {
      public void onClick(View v)
      {
          Restaurant r = new Restaurant();
          EditText name=(EditText)findViewById(R.id.name_enter);
          EditText address=(EditText)findViewById(R.id.address_enter);
          r.setName(name.getText().toString());
          r.setAddress(address.getText().toString());               
       }
  };
  }
  </code></pre>
  
  <p>Problem is that my application crashes everytime I start it. The logcat says that the error is in the line saves.setOnClickListener(onSave);</p>