public class MainActivity extends AppCompatActivity
implements View.OnClickListener {
private Button mButton;
private final String distance;
private final String time;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mButton = findViewById(R.id.button_send);
mButton.setOnClickListener(this);
}
@Override
public void onClick(View view)
{
estimateFare(this.distance, this.time)
}
}
You need to set your listener and then override the onClick method.
onClick will be called when the mButton will be pressed.