androidtrackball

Disable trackball click in Android


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();
}

Solution

  • 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.