0

I have this java code:

@override
public void onClick(View view){
if (view= btAdd)
{
db.execSQL("INSERT INTO student VALUES (+etstantID.getText()++etstantaxe.getText()+

+etStatProg.getText())" ahosdlessage ("Success", "Record added.");

clearText();
}
}

I implemeted OnClickLister and automatically generated the onlick method, I should've 4 buttons with different function, but when I try to call the onclick method using the constructor: Constructor constructorName = new Contructor(); When I try to: constructorName.onclick(); Im getting an error cuz I need to pass something on the onclick method but I don't know what and how, I declared every button the java using FindViewByID I need every button to have a unique function

  • Btw I tried to pass the button as parameter and I get no error but when I run the app, it doesn't work – Chunchunmaru Jun 06 '22 at 18:04
  • Tho it already make me implement the OnClickListener – Chunchunmaru Jun 06 '22 at 18:13
  • Note if this is an assignment for school, then your class should have provided the needed information to be able to complete it. Review your notes, lectures, and any other resource provided to you. Ask your teacher, teacher assistant, and/or tutors for help. Possibly even a classmate if your class allows you to work with other students. All these people will know how to help you with your assignment better than anyone here. – Slaw Jun 06 '22 at 18:23
  • I'm confused cuz I tried it and the app is still not working, by any chance, when I implement the Onlick listerner and the onClick method was generated what does it do? I mean I have 4 buttons an I'm trying to click a of them but thr app is not responding – Chunchunmaru Jun 06 '22 at 18:23
  • Jeez, never mind I just figure it out, I should just add *button.setOnClickListener(this::onClick)* – Chunchunmaru Jun 06 '22 at 18:26
  • On the main methid – Chunchunmaru Jun 06 '22 at 18:26

0 Answers0