Android - setOnClickListener for TextView

后端 未结 6 2045
孤街浪徒
孤街浪徒 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:33

    If you change your code to have this structure it will work:

    public void runNextTask(){
       ...
    }
    
    public void onClick(View v) {
    
    }
    

    as you're telling in your xml to capture the click for the text view (android:onClick="onClick") in onClick module, you don't need to add an onClick listener in your java code.

提交回复
热议问题