简体   繁体   中英

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.

Have an OnTouchListener class within your activity, or let your Activity implement 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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