Android examples for User Interface:Touch Event
Releases the focus on a view
//package com.java2s; import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; public class Main { /**//from ww w. j a v a2 s . co m * Releases the focus on a view * @param view */ public static void releaseFocus(View view) { ViewParent parent = view.getParent(); ViewGroup group = null; View child = null; while (parent != null) { if (parent instanceof ViewGroup) { group = (ViewGroup) parent; for (int i = 0; i < group.getChildCount(); i++) { child = group.getChildAt(i); if (child != view && child.isFocusable()) child.requestFocus(); } } parent = parent.getParent(); } } }