安卓错误信息解释请
问题描述:
有人可以解释下面的错误信息的含义吗?错误是:安卓错误信息解释请
java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.widget.TextView
答
你可能会做..
TextView text = (TextView)findViewById(R.id.image);
,其中的观点是图像按钮..
所以现在不能施放图像按钮的TextView ..它改变
ImageButton button= (ImageButton)findViewById(R.id.image);
答
你有一个对象,它是一个ImageButton的(也许从findViewById()
?),而你试图使特克斯tView出来(“铸造”)。它可能是这个样子
TextView yourView = (TextView) findViewById('yourButtonView');
而且你不能这样做
您使用'(的TextView)findViewById(R.id.someid)'但实际上查看该ID隐藏是'ImageButton' ... – Selvin 2012-04-20 13:20:31