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

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

    First make sure all TextView addressing the right TextView in your .java file.. Like this..

    TextView textview1 = (TextView) findViewById(R.id.textview1);
    

    Error like Android.widget,textView cannot be cast to android.widget,button raised because some time we referred Button instead of TextView.

    If everything is ok then Clean your project and refresh.. It worked for me..

提交回复
热议问题