大家好,这是有关android2.3 的鼠标设置问题,鼠标的响应事件都已经没有问题了,就是光标没有显示出来,我指导问题就在这下面的代码中,但本人水平有限,还是不能完全弄明白,请问大伙,这下面的代码中,哪里出现问题?让光标显示出来。谢谢。
// mouse cursor
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Path;    static final boolean DEBUG_MOUSE = false;
    // mouse cursor
    boolean mMouseActivate = false;
    Surface mMouseSurface;
    int mShowMouse = 0;
    int mMlx;
    int mMly;
    int mMlw;
    int mMlh;
    //Set position of mouse cursor
    // -------------------------------------------------------------
    private final class MouseHandler extends Handler {
        public static final int MOVE = 0;
        public static final int SHOW = 1;
        public static final int HIDE = 2;        public MouseHandler() {
        }        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case MOVE: {
                    if (mMouseSurface != null) {
                        synchronized (mWindowMap) {
                            Surface.openTransaction();
                            WindowState top = (WindowState)mWindows.get(mWindows.size() - 1);                            mMouseSurface.setPosition(mMlx,mMly);
                            mMouseSurface.setLayer(top.mAnimLayer + 1);
                            Surface.closeTransaction();
                        }
                    }
                } break;                case SHOW: {
                    if (mMouseSurface != null) {
                        synchronized (mWindowMap) {
                            Surface.openTransaction();
                            WindowState top = (WindowState)mWindows.get(mWindows.size() - 1);                            mMouseSurface.setPosition(mMlx,mMly);
                            mMouseSurface.setLayer(top.mAnimLayer + 1);
                            mMouseSurface.show();
                            Surface.closeTransaction();
                        }
                    }
                } break;                case HIDE: {
                    if (mMouseSurface != null) {
                        synchronized (mWindowMap) {
                            Surface.openTransaction();
                            mMouseSurface.hide();
                            Surface.closeTransaction();
                        }
                    }
                } break;
            }
        }
    }    MouseHandler mMouseHandler = new MouseHandler();        if (DEBUG_MOUSE)
            Log.i(TAG,"moving mouse " + mMouseSurface + " action " + action + " lx " + mMlx + " ly " + mMly + " nx " + mcx + " ny " + mcy);        if(action == -1) {
            mMouseActivate = false;
            mMouseHandler.sendEmptyMessage(MouseHandler.HIDE);        if(mcx>=0)    mMlx = mcx;
        if(mcy>=0)    mMly = mcy;        if(!mMouseActivate) {
            mMouseActivate = true;
            mMouseHandler.sendEmptyMessage(MouseHandler.SHOW);
        }
        else if(!mMouseHandler.hasMessages(MouseHandler.MOVE))
            mMouseHandler.sendEmptyMessage(MouseHandler.MOVE);        return 0;
    }        if(mMouseSurface == null) {
            int mMx, mMy, mMw, mMh;
            Canvas mCanvas;
            Path mPath = new Path();            if (DEBUG_INPUT)
                Log.i(TAG, "Create Mouse Surface");
            
            mMw = 20;
            mMh = 20;
            mMx = (mDisplay.getWidth() - mMw) / 2;
            mMy = (mDisplay.getHeight() - mMh) / 2;
            
            try {               
   mMouseSurface =
                        new Surface(mFxSession,
                                0, -1, mMw, mMh,
                                PixelFormat.TRANSPARENT,
                                Surface.FX_SURFACE_NORMAL);
                    mCanvas = mMouseSurface.lockCanvas(null);
                    Paint tPaint = new Paint();
                    tPaint.setStyle(Paint.Style.STROKE);
                    tPaint.setStrokeWidth(2);
                    tPaint.setColor(0xffffffff);
                    mPath.moveTo(0.0f, 0.0f);
                    mPath.lineTo(12.0f, 12.0f);
                    mPath.lineTo(7.0f, 12.0f);
                    mPath.lineTo(11.0f, 20.0f);
                    mPath.lineTo(8.0f, 21.0f);
                    mPath.lineTo(4.0f, 13.0f);
                    mPath.lineTo(0.0f, 17.0f);
                    mPath.close();
                    mCanvas.clipPath(mPath);
                    mCanvas.drawColor(0xff000000);
                    mCanvas.drawPath(mPath, tPaint);                    mMouseSurface.unlockCanvasAndPost(mCanvas);
                    mMouseSurface.openTransaction();
                    mMouseSurface.setSize(mMw, mMh);
                    mMouseSurface.closeTransaction();
                
            } catch (Exception e) {
                Log.e(TAG, "Exception creating mouse surface",e);
            }
            mMlx = mMx;
            mMly = mMy;
            mMlw = mMw;
            mMlh = mMh;
        }