我是一名新的 android 开发人员,我在我的应用程序中使用了 ImageButton
并在后台添加了一些图像。层中的一切看起来都不错,但是当我想在某个类中使用它并使用它下面的代码时;将强制关闭。
Help_Button = (Button) findViewById(R.id.Help_Button);
最佳答案
发布你的布局 xml 会有很大帮助,但我敢打赌,你会得到一个 ClassCastException
试图将 ImageButton
转换为 Button
。试试这个。-
ImageButton helpButton = (ImageButton) findViewById(R.id.Help_Button);
关于android - ImageButton 在类里面不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19326003/