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

前端 未结 11 637
你的背包
你的背包 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:26

    you are trying to cast TextView to Button.

    for TextView do this :

    TextView tv = (TextView)findviewById(R.id.your textviewid present in xml layout file);
    

    for Button :

    Button btn1 = (Button)findviewById(R.id.your buttonid present in xml layout file);
    

提交回复
热议问题