Android examples for User Interface:View Tag
Returns the tag associated with the given view.
/*//ww w . j ava 2 s . co m * Copyright 2014 Lorenzo Villani * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ //package com.java2s; import android.view.View; public class Main { /** * Returns the tag associated with the given view. * <p/> * The tag is automatically converted to the type of the object on the left of the assignment * (the lvalue type). * * @param view The view to query. * @param <T> The return type. * @return The Object stored in this view as a tag. * @see android.view.View#getTag() */ @SuppressWarnings("unchecked") public static <T> T getTag(final View view) { return (T) view.getTag(); } /** * Returns the tag associated with the given view and the specified key. * <p/> * The tag is automatically converted to the type of the object on the left of the assignment * (the lvalue type). * * @param view The view to query. * @param key The key identifying the tag. * @param <T> The return type. * @return The Object stored in this view as a tag. * @see android.view.View#getTag(int) */ @SuppressWarnings("unchecked") public static <T> T getTag(final View view, int key) { return (T) view.getTag(key); } }