如何解决无法解决按钮的代码Android Studio
我想通过单击另一个按钮 (ib_one) 来更改 ImageButton (ib_two) 的图像。
我将 onClick 方法 (android:onClick="") 放在 xml 文件中的按钮上:
<ImageButton
android:id="@+id/ib_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="162dp"
android:layout_marginTop="97dp"
android:layout_weight="1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@android:drawable/btn_star"
android:onClick="gameActionBtn1"
/>
在我想写的函数中:"ib_two.setsrcCompat = "@android:drawable/btn_star_glow"
fun gameActionBtn1(v: View?) {
Toast.makeText(this,"Game Actiob Button 1 geklickt",Toast.LENGTH_LONG).show()
ib_two *the text color is red*
}
当我想写代码时,“ib_two”是红色的。为什么IDE(Android Studio)无法“找到” 按钮 ID?或者还有什么问题?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。