关闭轨迹球点击Android中轨迹球、Android

2023-09-13 02:14:23 作者:奈我何i

我碰到的与执行自定义进度对话框一些困难。尽管覆盖拦截触摸事件,用户仍然可以操作的轨迹球,点击,都应该被禁用的元素。

有没有解决这个办法吗?

编辑:这里有一个解决方案

  // ==================================== =================================================
保护无效showProgressIndicator()
{
    progressIndicator_.show();
}

// ================================================ =====================================
@覆盖
公共布尔onTrackballEvent(MotionEvent事件)
{
    返回progressIndicator_.getVisibility()== View.VISIBLE;
}

// ================================================ =====================================
保护无效hideProgressIndicator()
{
    progressIndicator_.hide();
}
 

这是再在显示方法

  // ==================================== =================================================
公共无效展()
{
    setVisibility(可见);
    如果(animationHandler_!= NULL)
        返回;

    animationHandler_ =新的处理程序();
    animationHandler_.post(animateTask_);
    requestFocus的();
}
 

解决方案

检查 onTrackballEvent()方法。然后尝试在方法直接返回true而不做的任何事情。这应该杀事件的时候了。

盘点曾被大肆炒作的10款手机

I've run into some difficulties with implementing a custom progress dialog. Even though an overlay intercepts touch events the user can still operate the trackball and click elements that are supposed to be disabled.

Is there any way around this?

Edit: here's a solution

//=====================================================================================
protected void showProgressIndicator()
{
    progressIndicator_.show();
}

//=====================================================================================
@Override
public boolean onTrackballEvent(MotionEvent event)
{
    return progressIndicator_.getVisibility() == View.VISIBLE;
}

//=====================================================================================
protected void hideProgressIndicator()
{
    progressIndicator_.hide();
}

An then in show method

//=====================================================================================
public void show()
{
    setVisibility(VISIBLE);
    if (animationHandler_ != null)
        return;

    animationHandler_ = new Handler();
    animationHandler_.post(animateTask_);
    requestFocus();
}

解决方案

Check the onTrackballEvent() method. Then try to directly returning true in the method without doing anything in it. This should kill the event right away.