set View Selected - Android User Interface

Android examples for User Interface:View Property

Description

set View Selected

Demo Code


//package com.java2s;
import android.app.Activity;

import android.support.annotation.IdRes;

import android.view.View;

public class Main {
    public static void setSelected(Activity activity, @IdRes int viewId) {
        View view = findView(activity, viewId);
        view.setSelected(true);//from  w w  w.j  av  a  2 s.c  o m
    }

    public static <T extends View> T findView(View parent, @IdRes int viewId) {
        return (T) parent.findViewById(viewId);
    }

    public static <T extends View> T findView(Activity activity,
            @IdRes int viewId) {
        return (T) activity.findViewById(viewId);
    }
}

Related Tutorials