我正在学习VB.NET中的键盘钩子,需要帮助解决错误。起初它告诉我必须改变(Not(KeyDown)Is Nothing)& KeyUp to RaiseEvent因为它们是事件,我已经完成了。但现在它告诉我一个')'表达是预期的,我不知道这意味着什么。我使用VB.NET wiki和代码片段做到了这一点,我为自己感到骄傲。我现在不希望这个翻牌。请帮忙!最底层有一个错误的图像。
protected static void setAnimatedImagesForImageView(final Context context, ImageView imageView, Uri[] imageUris, int showImageDurationMillis, int fadeImageDurationMillis) {
AnimationDrawable animation = new AnimationDrawable();
animation.setEnterFadeDuration(fadeImageDurationMillis);
animation.setExitFadeDuration(fadeImageDurationMillis);
boolean imageAdded = false;
for (int i = 0; i < imageUris.length; i++) {
if (imageUris[i] != null) {
Drawable drawable = getDrawable(context, imageUris[i]);
animation.addFrame(drawable, showImageDurationMillis);
imageAdded = true;
}
}
if (imageAdded) {
animation.setOneShot(false);
imageView.setImageDrawable(animation);
animation.start();
}
}
答案 0 :(得分:1)
你应该只是举起事件..如果有什么东西在听它,它就会运行。如果没有,则不会造成伤害。
Public Event KeyDown As KeyboardHookCallback
Public Event KeyUp As KeyboardHookCallback
Private Function HookFunc(ByVal nCode As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
If (nCode >= 0) Then
Dim iwParam As Integer = wParam.ToInt32
If ((iwParam = WM_KEYDOWN) OrElse (iwParam = WM_SYSKEYDOWN)) Then
RaiseEvent KeyDown(CType(Marshal.ReadInt32(lParam), VKeys))
End If
If ((iwParam = WM_KEYUP) OrElse (iwParam = WM_SYSKEYUP)) Then
RaiseEvent KeyUp(CType(Marshal.ReadInt32(lParam), VKeys))
End If
End If
Return CallNextHookEx(hookID, nCode, wParam, lParam)
End Function