Example usage for android.view View setId

List of usage examples for android.view View setId

Introduction

In this page you can find the example usage for android.view View setId.

Prototype

public void setId(@IdRes int id) 

Source Link

Document

Sets the identifier for this view.

Usage

From source file:Main.java

public static void injectViewInLayout(ViewGroup viewGroup, int id) {
    View view = View.inflate(viewGroup.getContext(), id, null);
    view.setId(id);
    viewGroup.addView(view);// w w  w  . java  2 s  .c o m
}

From source file:fr.shywim.antoinedaniel.utils.Utils.java

/**
 * First part of the click animation./* w  w  w.  jav  a2s .co m*/
 *
 * @param context Any context.
 * @param v View who will have the effect.
 * @param isRoot Whether the passed view is the ViewGroup parent.
 */
public static void clickAnimDown(Context context, View v, boolean isRoot) {
    RelativeLayout root;
    if (isRoot)
        root = (RelativeLayout) v;
    else
        root = (RelativeLayout) v.getParent();
    final View rectView = new View(context);
    rectView.setId(R.id.rect_view_id);
    rectView.setVisibility(View.GONE);
    rectView.setBackgroundResource(R.drawable.square);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(v.getMeasuredWidth(),
            v.getMeasuredHeight());
    params.addRule(RelativeLayout.ALIGN_TOP, v.getId());
    rectView.setLayoutParams(params);
    AlphaAnimation rectAnim = new AlphaAnimation(0f, 0.4f);
    rectAnim.setFillAfter(true);
    rectAnim.setInterpolator(new AccelerateInterpolator());
    rectAnim.setDuration(150);
    rectAnim.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            rectView.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animation animation) {

        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    root.addView(rectView);
    rectView.startAnimation(rectAnim);
}

From source file:com.alibaba.weex.WXPageActivity.java

/**
 *
 * @param map <weexid,viewId>//from  ww w . j  a  v a2 s  .c o m
 */
private static void collectId(WXComponent comp, Map<String, String> map) {
    if (comp == null) {
        return;
    }
    ImmutableDomObject dom;
    String id;
    View view;
    if ((view = comp.getHostView()) != null && (dom = comp.getDomObject()) != null
            && (id = (String) dom.getAttrs().get("testId")) != null && !map.containsKey(id)) {
        Pair<String, Integer> pair = Utility.nextID();
        view.setId(pair.second);
        map.put(id, pair.first);
    }
    if (comp instanceof WXVContainer) {
        WXVContainer container = (WXVContainer) comp;
        for (int i = container.getChildCount() - 1; i >= 0; i--) {
            collectId(container.getChild(i), map);
        }
    }
}

From source file:com.telenav.expandablepager.ExpandablePagerAdapter.java

/**
 * Attaches the view to the container and gives it a specific id. Return the result of this method when overriding {@link #instantiateItem(ViewGroup, int)}
 * @param container view container/*w w  w  . j  a v a2  s  .  c om*/
 * @param v inflated view
 * @param position position of the view in the adapter
 * @return inflated view
 */
protected View attach(ViewGroup container, View v, int position) {
    v.setId(ExpandablePager.INTERNAL_PAGE_ID + position);
    container.addView(v);
    return v;
}

From source file:com.telenav.expandablepager.adapter.ExpandablePagerAdapter.java

/**
 * Attaches the view to the container and gives it a specific id. Return the result of this method when overriding {@link #instantiateItem(ViewGroup, int)}
 * @param container view container/*from  w  w w  .ja  va 2  s  . com*/
 * @param v inflated view
 * @param position position of the view in the adapter
 * @return inflated view
 */
protected View attach(ViewGroup container, View v, int position) {
    v.setId(R.id.internal_page_id % 10000 + position);
    container.addView(v);
    return v;
}

From source file:com.ls.drupal8demo.ArticleActivity.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    int contentId = 1001;
    ActionBar bar = this.getSupportActionBar();
    bar.setDisplayShowHomeEnabled(true);
    bar.setDisplayHomeAsUpEnabled(true);
    String previewString = getIntent().getStringExtra(ARTICLE_PREVIEW_KEY);

    ArticlePreview preview = SharedGson.getGson().fromJson(previewString, ArticlePreview.class);
    InitHeaderWithPreview(preview);/* w ww . j  a va 2s .c o m*/

    View content = new FrameLayout(this);
    content.setId(contentId);
    setContentView(content);

    ArticleFragment articleFragment = ArticleFragment.newInstance(preview.getNid(), preview.getImage());
    FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
    trans.add(contentId, articleFragment);
    trans.commit();
}

From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.FeedMapFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ContentResolver resolver = getActivity().getContentResolver();
    resolver.registerContentObserver(mFeedUri, true, mFeedObserver);

    View view = new WebView(getActivity());
    view.setLayoutParams(LAYOUT_FULL_WIDTH);
    view.setId(android.R.id.custom);
    return view;// w w  w .  j  ava  2  s  .  c o  m
}

From source file:com.frostwire.android.gui.views.AbstractListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(resource, container, false);

    View progressContainer = v.findViewById(R.id.progressContainer);
    if (progressContainer != null) {
        progressContainer.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    }// w  ww  .  j  av  a  2 s. c  o m
    View listContainer = v.findViewById(R.id.listContainer);
    if (listContainer != null) {
        listContainer.setId(INTERNAL_LIST_CONTAINER_ID);
    }

    if (!v.isInEditMode()) {
        initComponents(v);
    }

    return v;
}

From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.FeedHeadFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    View tabs = getActivity().findViewById(R.id.tab_frame);
    if (tabs != null) {
        tabs.setVisibility(View.GONE);
    }//from   w  w w. j  av a2  s . com
    View view = inflater.inflate(R.layout.objects_item, container, false);
    view.setLayoutParams(CommonLayouts.FULL_WIDTH);
    view.setId(R.id.feed_view);
    return view;
}

From source file:de.persoapp.android.activity.fragment.DataFragment.java

@SuppressWarnings("ConstantConditions")
protected void increaseIds(ViewGroup viewGroup) {
    for (int i = viewGroup.getChildCount() - 1; i >= 0; i--) {
        View view = viewGroup.getChildAt(i);
        view.setId(view.getId() + 100);
    }//  ww  w.  java  2  s. com
}