Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.app.Activity;

import android.view.View;

public class Main {
    /**
     * <prev>
     * Remove focus on every child views of an activity.
     * </prev>
     */
    public static void focusNothing(Activity activity) {
        focusNothing(getRootView(activity));
    }

    private static void focusNothing(View rootView) {
        rootView.setFocusableInTouchMode(true);
        rootView.requestFocus();
    }

    /**
     * <prev>
     * Get root view of an activity.
     * </prev>
     */
    public static View getRootView(Activity activity) {
        return activity.getWindow().getDecorView().findViewById(android.R.id.content);
    }
}