Reputation: 91
I have three files such as
From my resource file, on a button click I am calling a method (add). The method is defined in the DB Class. and I am trying to call it from the fragment class related with the res file. But when I do I am getting an error:
Could not find a method add(View) in the activity class MainActivity for onClick handler on view class android.widget.Button with id 'btStartCall'
I think I need to initialize the method in activity class to use it. But I am not sure how to do it. Can anyone help me with a simple example?
Upvotes: 0
Views: 179
Reputation: 47807
But when i do I am getting an error telling "Could not find a method add(View) in the activity class MainActivity for onClick handler on view class android.widget.Button with id 'btStartCall'"
You should add add(View)
method in your MainActivity
just like:
public void add(View v){
//do your job
}
Upvotes: 1