-6

I want to call this method in onClick

public void estimateFare(final String distance, final String time){

      //more code

}
Vega
  • 27,856
  • 27
  • 95
  • 103
Sandy
  • 1
  • 5

1 Answers1

0
       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.