2012-04-20 74 views
0

有人可以解釋下面的錯誤信息的含義嗎?錯誤是:安卓錯誤信息解釋請

java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.widget.TextView 
+0

您使用'(的TextView)findViewById(R.id.someid)'但實際上查看該ID隱藏是'ImageButton' ... – Selvin 2012-04-20 13:20:31

回答

5

你可能會做..

TextView text = (TextView)findViewById(R.id.image); 

,其中的觀點是圖像按鈕..

所以現在不能施放圖像按鈕的TextView ..它改變

ImageButton button= (ImageButton)findViewById(R.id.image); 
0

你有一個對象,它是一個ImageButton的(也許從findViewById()?),而你試圖使特克斯tView出來(「鑄造」)。它可能是這個樣子

TextView yourView = (TextView) findViewById('yourButtonView'); 

而且你不能這樣做