最后我有一个工作......
只需覆盖 MediaRouteButton,覆盖其 performClick() 方法,插入您想要执行的逻辑。
public class CustomizedChromesCastButton extends MediaRouteButton {
private boolean enable = true;
public CustomizedChromesCastButton( Context context ){
super( context );
}
public CustomizedChromesCastButton(Context context, AttributeSet attrs){
super( context, attrs );
}
public CustomizedChromesCastButton(Context context, AttributeSet attrs, int defStyleAttr){
super( context, attrs, defStyleAttr );
}
public void setCastEnable( boolean enable ){
this.enable = enable;
}
public boolean performClick(){
if( enable ){
return super.performClick();
}
else {
return false;
}
}
}