Android - setOnClickListener for TextView

后端 未结 6 1969
孤街浪徒
孤街浪徒 2021-02-05 10:47

It should be straightforward, but I am not sure where something is wrong. I try to catch the click on the TextView with:

public void runNextTask(){
         


        
6条回答
  •  心在旅途
    2021-02-05 11:30

    This line: android:onClick="onClick" Tells Android to look in the activity for a method with this signature:

    public void onClick(View v)
    

    This wasn't your intention, as you've set the OnClickListener inside your code and haven't created the dedicated method for it in the activity. So your options are either to simply remove the android:onClick="onClick" from your xml file or remove the on click listener you've created and change it to an onClick method (and preferablly change it's name to something better than onClick...

提交回复
热议问题