题
我碰到与实现自定义的进度对话框一些困难。即使覆盖截取触摸事件的用户仍可以操作轨迹球,然后按一下应该是禁用的元素。
有没有解决这个办法吗?
编辑:这里的溶液
//=====================================================================================
protected void showProgressIndicator()
{
progressIndicator_.show();
}
//=====================================================================================
@Override
public boolean onTrackballEvent(MotionEvent event)
{
return progressIndicator_.getVisibility() == View.VISIBLE;
}
//=====================================================================================
protected void hideProgressIndicator()
{
progressIndicator_.hide();
}
这是在随后显示方法
//=====================================================================================
public void show()
{
setVisibility(VISIBLE);
if (animationHandler_ != null)
return;
animationHandler_ = new Handler();
animationHandler_.post(animateTask_);
requestFocus();
}
解决方案
检查 onTrackballEvent() 方法。然后尝试直接返回true的方法,无需在做任何事情。这应该杀事件的时候了。
其他提示
为了防止您的轨迹球做任何事情,而你的活动是在屏幕上,下面的代码添加到您的Activity子类。
@Override
public boolean dispatchTrackballEvent(android.view.MotionEvent ev) {
return true;
};
我一个谷歌Nexus One手机上测试这和它工作得很好。
覆盖onTrackballEvent()不工作。 尝试重写dispatchTrackballEvent(),什么也不做,它只是返回true;
不隶属于 StackOverflow