gpt4 book ai didi

java - Android:在 XML 中指定 onClick() 成员方法?

转载 作者:行者123 更新时间:2023-12-01 15:40:19 25 4
gpt4 key购买 nike

我的 XML 布局如下:

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:onClick="myButton.performClick" />

myButton 是此 Activity 的成员,是否可以在此处使用类成员方法?

最佳答案

is it possible use a class member method here?

根据 API - 没有。 API says :

Name of the method in this View's context to invoke when the view is clicked. This name must correspond to a public method that takes exactly one parameter of type View.

关于java - Android:在 XML 中指定 onClick() 成员方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8160060/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com