Click And Focus On View - Android User Interface

Android examples for User Interface:Touch Event

Description

Click And Focus On View

Demo Code


//package com.java2s;

import android.view.View;
import android.view.ViewGroup;

public class Main {
    public static void ClickAndFocusOnView(View v) {
        if (v.getParent() instanceof ViewGroup) {
            v.getParent().requestChildFocus(v, v);
            v.performClick();// ww w  . j  a  va  2s  .  c o  m
        } else {
            v.performClick();
        }
    }
}

Related Tutorials