誰かが以下のエラーメッセージの意味を説明できますか? エラーは次のとおりです。
java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.widget.TextView
誰かが以下のエラーメッセージの意味を説明できますか? エラーは次のとおりです。
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()
?) であるオブジェクトがあり、それから TextView を作成しようとしています (「キャスト」)。それはこのように見えるかもしれません
TextView yourView = (TextView) findViewById('yourButtonView');
そして、あなたはそれを行うことはできません