I keep getting a runtime error when launching my activity and it says android.widget.textview cannot be cast to android.widget.button?
XML:
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);
Please attach your java code to find out where the problem is occuring. This problem comes when you are trying to convert the textview to button.
Project -> Clean can help you.
Or
it help :D
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(...)