Android通过反射设置onClick事件

在原有的onClick基础上添加新的后续操作

        Class viewClazz = View.class;
try {
Field infoField = viewClazz.getDeclaredField("mListenerInfo");
infoField.setAccessible(true); //无视访问修饰符
Object listenerInfo = infoField.get(videoplayer.fullscreenButton);

Class infoClazz = Class.forName("android.view.View$ListenerInfo");
Field listenerField = infoClazz.getDeclaredField("mOnClickListener");
listenerField.setAccessible(true); //无视访问修饰符
final View.OnClickListener clickListener = (View.OnClickListener)listenerField.get(listenerInfo);
listenerField.set(listenerInfo, new View.OnClickListener() {
@Override
public void onClick(View v) {
clickListener.onClick(v);
mToast.showMessage("Hello!");
}
});
} catch (Exception e) {
e.printStackTrace();
}