简体   繁体   English

如何在处理时使整个android屏幕(当前)无响应?

[英]How to make whole android screen (current) unresponsive while processing?

I have one activity, which contains header (title bar). 我有一个活动,其中包含标题(标题栏)。 This header also contains the image of Sync feature of my app. 此标题还包含我的应用程序的“同步”功能的图像。 As per requirement of client, I want that when the user tap on this button, the animation of this image (button) starts, which is rotating animation (I've achieved this animation). 根据客户的要求,我希望当用户点击此按钮时,此图像(按钮)的动画开始,这是旋转动画(我已经实现了此动画)。 But while this animation is being performed, I want to freeze the whole screen so the user can not tap on other views while sync is in progress. 但是,在执行此动画时,我想冻结整个屏幕,以便在同步过程中用户无法点击其他视图。 Till now I've used the following method but with no success : 到目前为止,我已经使用了以下方法,但没有成功:

private boolean stopUserInteractions = false;
    public boolean dispatchTouchEvent(int i) {
    View v = imgSync;
    if (v.getId() == R.list.imgSync) {
        System.out.println("UI Blocked...");
        return false;
        } 
    else {
            return super.dispatchTouchEvent(ev);
        }

        return false;
}

Can anyone guide me for this? 有人可以为此指导我吗? Any trick/snippet or any other hint. 任何技巧/片段或任何其他提示。 EDIT : I dont want to use ProgressDialog while this sync process is being happening. 编辑 :此同步过程正在发生时,我不想使用ProgressDialog。

Have an OnTouchListener class within your activity, or let your Activity implement OnTouchListener. 在您的活动中包含一个OnTouchListener类,或者让您的Activity实现OnTouchListener。 All children of the activity's layout should set a single object of this if they want to listen touch events. 如果活动的布局的所有子项都想监听触摸事件,则应为此设置一个对象。 Within listener, check whether you should process the click or not. 在侦听器中,检查是否应处理单击。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM