可以setEnabled()函数可以被覆盖,如果是这样如何?(Can setEnabled() Function can be overidden,if so how?)

编程入门 行业动态 更新时间:2024-10-28 07:24:30
可以setEnabled()函数可以被覆盖,如果是这样如何?(Can setEnabled() Function can be overidden,if so how?) public class AppaSwitch extends AppCompatImageButton implements View.OnClickListener { @Override public void onClick(View v) { } }

像上面的code有一种方法来覆盖android setEnabled()函数。下面是一个例子,但我看不到像这样的方法

public class AppaSwitch extends AppCompatImageButton implements View.OnEnabled { @Override public void OnEnabled(View v) { } }

或者有没有其他方法可以做到这一点?

public class AppaSwitch extends AppCompatImageButton implements View.OnClickListener { @Override public void onClick(View v) { } }

Like the above code is there a way to override setEnabled() function in android.The below is an example but I see no method like this

public class AppaSwitch extends AppCompatImageButton implements View.OnEnabled { @Override public void OnEnabled(View v) { } }

Or is there any alternate way of doing this ?

最满意答案

setEnabled()是View类的方法, AppCompatImageButton已经扩展了View Class,所以你可以直接覆盖这里所做的:

public class AppaSwitch extends AppCompatImageButton { @Override public void setEnabled(boolean enabled) { //your piece of code //if you want to remove below line to remove the function of super class. super.setEnabled(enabled); } }

setEnabled() is the method of View class and AppCompatImageButton already extends View Class, so you can directly override as done here:

public class AppaSwitch extends AppCompatImageButton { @Override public void setEnabled(boolean enabled) { //your piece of code //if you want to remove below line to remove the function of super class. super.setEnabled(enabled); } }

更多推荐

本文发布于:2023-07-31 02:47:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1340413.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:被覆   是这样   函数   setEnabled   Function

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!