Android.widget,textView cannot be cast to android.widget,button

前端 未结 11 638
你的背包
你的背包 2020-12-08 05:01

I keep getting a runtime error when launching my activity and it says android.widget.textview cannot be cast to android.widget.button?

XML:



        
11条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 05:37

    I just encountered the same problem. However, i decided to use only "View" without casting. It works perfectly. "setOnClickListener" works the same for our case.

    e.g. View button = v.findViewById(button_id); button.setOnClickListener(...)

提交回复
热议问题