“Could not find a method .. in the activity class .. for onClick handler”

后端 未结 3 1331
被撕碎了的回忆
被撕碎了的回忆 2020-12-12 00:43

I am working on my first android project. I am using the thinkgear api. I have two activities. I have an intent in the first activity calling to start the second activity. I

相关标签:
3条回答
  • 2020-12-12 01:18

    See the Documentation, in this example sendMessage method uses:

    a View as its only parameter (this will be the View that was clicked).

    Your error:

    Could not find a method play(View) in the activity class com.example.mindwave1.SecondPageActivity for onClick handler on view class android.widget.Button with id 'button1'  
    

    You need to use the View parameter in your method. The solution:

    public void play(View view){
        ...
    }  
    
    0 讨论(0)
  • 2020-12-12 01:26

    Woah format that log or something in the future. Your problem is

    Could not find a method play(View) in the activity class com.example.mindwave1.SecondPageActivity for onClick handler on view class android.widget.Button with id 'button1' 04-16 16:39:51.676: E/AndroidRuntime(13927):

    You probably have a function "play" defined on the onclick xml attribute. This function passes in the view as well, so your method signature needs to look like

    public void play(View view){
    ... 
    }
    
    0 讨论(0)
  • 2020-12-12 01:29

    Your method

    public void play(){
    

    is missing the parameter

    public void play(View v){
    
    0 讨论(0)
提交回复
热议问题