set View Not Selected - Android User Interface

Android examples for User Interface:View Property

Description

set View Not 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 setNotSelected(Activity activity, @IdRes int viewId) {
        View view = findView(activity, viewId);
        view.setSelected(false);//from ww w.  ja  v a  2 s  .  com
    }

    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);
    }

    public static void setSelected(Activity activity, @IdRes int viewId) {
        View view = findView(activity, viewId);
        view.setSelected(true);
    }
}

Related Tutorials