Example usage for android.view ViewGroup setTag

List of usage examples for android.view ViewGroup setTag

Introduction

In this page you can find the example usage for android.view ViewGroup setTag.

Prototype

public void setTag(int key, final Object tag) 

Source Link

Document

Sets a tag associated with this view and a key.

Usage

From source file:org.ayo.animate.transition.TransitionManager.java

private static ArrayList<Transition> getRunningTransitions(ViewGroup viewGroup) {
    ArrayList<Transition> transitions = (ArrayList<Transition>) viewGroup.getTag(R.id.runningTransitions);
    if (transitions == null) {
        transitions = new ArrayList<Transition>();
        viewGroup.setTag(R.id.runningTransitions, transitions);
    }/*from ww  w  .  jav  a 2  s. c o  m*/
    return transitions;
}

From source file:li.barter.fragments.NavDrawerFragment.java

/**
 * Initialize the profile header views. Reads the references to the child views and stores them
 * as tags/*from w  w  w  . j  a v  a  2  s  .c  o  m*/
 */
private void initProfileHeaderViews() {

    //Get references to the two primary containers
    final ViewGroup profileContainer = (ViewGroup) mProfileHeader.findViewById(R.id.container_profile_info);
    mProfileHeader.setTag(R.id.container_profile_info, profileContainer);

    final ViewGroup signInContainer = (ViewGroup) mProfileHeader.findViewById(R.id.container_sign_in_message);
    mProfileHeader.setTag(R.id.container_sign_in_message, signInContainer);

    //Get references to the individual container children and set tags
    profileContainer.setTag(R.id.text_user_name, profileContainer.findViewById(R.id.text_user_name));
    profileContainer.setTag(R.id.image_user, profileContainer.findViewById(R.id.image_user));

    TextView textView = (TextView) signInContainer.findViewById(R.id.text_nav_item_title);
    textView.setText(R.string.text_sign_in);
    signInContainer.setTag(R.id.text_nav_item_title, textView);

}

From source file:mobisocial.musubi.ui.widget.DbObjCursorAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    Cursor cursor = getCursor();/*  w w  w .j a v a 2  s. c o m*/

    if (!moveCursorToPosition(cursor, position)) {
        throw new IllegalStateException("couldn't move cursor to position " + position);
    }

    DbObjCursor row;
    if (convertView == null) {
        row = DbObjCursor.getInstance(mDbManager, cursor);
    } else {
        row = DbObjCursor.getInstance(mDbManager, cursor, (DbObjCursor) convertView.getTag(R.id.object_entry));
    }

    FeedRenderer renderer = ObjHelpers.getFeedRenderer(row.type);
    ViewGroup objectMainView;
    ViewHolder viewHolder;
    if (convertView == null) {
        viewHolder = new ViewHolder();
        LayoutInflater inflater = LayoutInflater.from(mContext);
        objectMainView = (ViewGroup) inflater.inflate(R.layout.objects_item, parent, false);
        viewHolder.frame = (ViewGroup) objectMainView.findViewById(R.id.object_content);
        viewHolder.objView = renderer.createView(mContext, viewHolder.frame);
        viewHolder.frame.addView(viewHolder.objView);
        viewHolder.error = objectMainView.findViewById(R.id.error_text);
        viewHolder.senderIcon = (ImageView) objectMainView.findViewById(R.id.icon);
        viewHolder.senderName = (TextView) objectMainView.findViewById(R.id.name_text);
        viewHolder.timeText = (TextView) objectMainView.findViewById(R.id.time_text);
        viewHolder.sendingIcon = (ImageView) objectMainView.findViewById(R.id.sending_icon);
        viewHolder.attachmentsIcon = (ImageView) objectMainView.findViewById(R.id.obj_attachments_icon);
        viewHolder.attachmentsText = (TextView) objectMainView.findViewById(R.id.obj_attachments);
        viewHolder.addContact = (TextView) objectMainView.findViewById(R.id.add_contact);

        objectMainView.setTag(R.id.holder, viewHolder);
        objectMainView.setTag(R.id.object_entry, row);
    } else {
        objectMainView = (ViewGroup) convertView;
        viewHolder = (ViewHolder) objectMainView.getTag(R.id.holder);
    }

    ObjHelpers.bindObjViewFrame(mContext, mDbManager, objectMainView, viewHolder, row);
    boolean allowInteractions = true;

    try {
        renderer.render(mContext, viewHolder.objView, row, allowInteractions);
        viewHolder.error.setVisibility(View.GONE);
        viewHolder.frame.setVisibility(View.VISIBLE);
    } catch (Exception e) {
        viewHolder.error.setVisibility(View.VISIBLE);
        viewHolder.frame.setVisibility(View.GONE);
        Log.e(getClass().getSimpleName(), "Error rendering type " + row.type, e);
    }
    return objectMainView;
}