Example usage for android.view ViewGroup getContext

List of usage examples for android.view ViewGroup getContext

Introduction

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

Prototype

@ViewDebug.CapturedViewProperty
public final Context getContext() 

Source Link

Document

Returns the context the view is running in, through which it can access the current theme, resources, etc.

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);//from  www . j a v  a  2  s  .  co  m
    viewGroup.addView(view);
}

From source file:Main.java

public static View inflate(@NonNull ViewGroup parent, @LayoutRes int layoutRes) {
    return inflate(parent.getContext(), parent, layoutRes);
}

From source file:com.normalexception.app.rx8club.view.threaditem.ThreadItemView.java

/**
 * Inflate the view, this technically only gets called the first time the
 * view is accessed/*from   w ww. j  a v  a 2s .c o m*/
 * @param parent   The parent of the view
 * @return         An inflated object
 */
public static ThreadItemView inflate(ViewGroup parent) {
    ThreadItemView threadView = (ThreadItemView) LayoutInflater.from(parent.getContext())
            .inflate(R.layout.view_newthread, parent, false);
    return threadView;
}

From source file:com.bilibili.socialize.share.utils.selector.BaseSharePlatformSelector.java

protected static GridView createShareGridView(final Context context,
        AdapterView.OnItemClickListener onItemClickListener) {
    GridView grid = new GridView(context);
    ListAdapter adapter = new ArrayAdapter<ShareTarget>(context, 0, shareTargets) {
        // no need scroll
        @Override//from   w  ww.  jav  a2  s .  c  om
        public View getView(int position, View convertView, ViewGroup parent) {
            View view = LayoutInflater.from(parent.getContext())
                    .inflate(R.layout.bili_socialize_shareboard_item, parent, false);
            view.setBackgroundDrawable(null);
            ImageView image = (ImageView) view.findViewById(R.id.bili_socialize_shareboard_image);
            TextView platform = (TextView) view.findViewById(R.id.bili_socialize_shareboard_pltform_name);

            ShareTarget target = getItem(position);
            image.setImageResource(target.iconId);
            platform.setText(target.titleId);
            return view;
        }
    };
    grid.setNumColumns(-1);
    grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
    grid.setColumnWidth(context.getResources().getDimensionPixelSize(R.dimen.bili_socialize_shareboard_size));
    grid.setLayoutParams(new ViewGroup.LayoutParams(-1, -2));
    grid.setSelector(R.drawable.bili_socialize_selector_item_background);
    grid.setAdapter(adapter);
    grid.setOnItemClickListener(onItemClickListener);
    return grid;
}

From source file:com.google.android.feeds.ContentDecorator.java

private static LayoutInflater getLayoutInflater(ViewGroup parent) {
    Context context = parent.getContext();
    return LayoutInflater.from(context);
}

From source file:com.normalexception.app.rx8club.view.category.CategoryView.java

/**
 * Inflate the view, this technically only gets called the first time the
 * view is accessed//from  w w w. j a  v a2s.  c o m
 * @param parent   The parent of the view
 * @return         An inflated object
 */
public static CategoryView inflate(ViewGroup parent) {
    CategoryView categoryView = (CategoryView) LayoutInflater.from(parent.getContext())
            .inflate(R.layout.view_category, parent, false);
    return categoryView;
}

From source file:Main.java

public static ViewGroup getPlacer(ViewGroup container) {
    if (NEEDS_FRAME_LAYOUT_HACK) {
        // Insert RelativeLayout to be able to setMargin because pre-Honeycomb FrameLayout
        // could not handle setMargin properly.
        final ViewGroup placer = new RelativeLayout(container.getContext());
        container.addView(placer);//from   ww  w  .  j  a  v a 2 s .  c o  m
        return placer;
    } else {
        return container;
    }
}

From source file:com.normalexception.app.rx8club.view.threadpost.PostView.java

/**
 * Inflate the view, this technically only gets called the first time the
 * view is accessed/*from w  w  w . j a  v  a 2  s .c o  m*/
 * @param parent   The parent of the view
 * @return         An inflated object
 */
public static PostView inflate(ViewGroup parent) {
    PostView itemView = (PostView) LayoutInflater.from(parent.getContext()).inflate(R.layout.view_newreply,
            parent, false);
    return itemView;
}

From source file:com.appnexus.opensdkapp.SettingsFragment.java

private static Spinner initDropdown(View out, ViewGroup container, int resId, int stringsId) {
    Spinner dropdown = (Spinner) out.findViewById(resId);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(container.getContext(), stringsId,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    dropdown.setAdapter(adapter);//  w  w w  . j  a  va  2  s  .  c  o m
    return dropdown;
}

From source file:android.support.transition.ViewOverlayApi14.java

static ViewOverlayApi14 createFrom(View view) {
    ViewGroup contentView = getContentView(view);
    if (contentView != null) {
        final int numChildren = contentView.getChildCount();
        for (int i = 0; i < numChildren; ++i) {
            View child = contentView.getChildAt(i);
            if (child instanceof OverlayViewGroup) {
                return ((OverlayViewGroup) child).mViewOverlay;
            }/*from   www.j  a  va2 s.  co m*/
        }
        return new ViewGroupOverlayApi14(contentView.getContext(), contentView, view);
    }
    return null;
}