可以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); } }更多推荐
发布评论