List of usage examples for android.view ViewGroup getContext
@ViewDebug.CapturedViewProperty public final Context getContext()
From source file:fr.cph.chicago.core.adapter.PopupBusDetailsFavoritesAdapter.java
@Override public final View getView(final int position, final View convertView, final ViewGroup parent) { final LayoutInflater vi = (LayoutInflater) parent.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View rowView = vi.inflate(R.layout.popup_bus_cell_0, parent, false); final TextView textView = (TextView) rowView.findViewById(R.id.label); final String toDisplay = values.get(position).getStopName() + " (" + WordUtils.capitalize(values.get(position).getBound().toLowerCase()) + ")"; textView.setText(toDisplay);/*from w w w . ja v a 2 s. c o m*/ return rowView; }
From source file:com.manuelpeinado.numericpageindicator.demo.MyPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { TextView item = new TextView(container.getContext()); item.setText(Integer.toString(position + 1)); item.setTextColor(Color.argb(192, 255, 255, 255)); item.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 50); item.setGravity(Gravity.CENTER);/*w ww. j ava 2 s .c o m*/ item.setBackgroundColor(COLORS[position % COLORS.length]); ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); container.addView(item, layoutParams); return item; }
From source file:com.yanzhenjie.nohttp.sample.adapter.MainBannerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { ImageView imageView = new ImageView(container.getContext()); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setImageResource(IMAGES[position % IMAGES.length]); container.addView(imageView);//from w w w . j av a2s. c om return imageView; }
From source file:com.example.android.leanback.StringPresenter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { Log.d(TAG, "onCreateViewHolder"); final Context context = parent.getContext(); TextView tv = new TextView(context); tv.setFocusable(true);//w ww . j a v a2s. c o m tv.setFocusableInTouchMode(true); tv.setBackground( ResourcesCompat.getDrawable(context.getResources(), R.drawable.text_bg, context.getTheme())); return new ViewHolder(tv); }
From source file:com.lamcreations.scaffold.common.adapters.ImagePagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { Context context = container.getContext(); View view = LayoutInflater.from(context).inflate(getLayoutResId(), container, false); bindView(view, position);//from ww w . ja v a 2s . c om container.addView(view); return view; }
From source file:com.liferay.mobile.screens.viewsets.defaultviews.ddl.pager.DDLFormPagerViewAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { Context context = container.getContext(); Field field = fields.get(position); Field.EditorType type = field.getEditorType(); int layoutId = layoutIds.get(type); LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(layoutId, container, false); DDLFieldViewModel viewModel = (DDLFieldViewModel) view; viewModel.setField(field);// w w w . j av a 2s .co m container.addView(view); return view; }
From source file:adamin.com.dragandswiperecyclerview.RecyclerGridFragment.java
@Nullable @Override/* w w w .ja v a 2s. co m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return new RecyclerView(container.getContext()); }
From source file:com.example.draganddrop.ItemAdapter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(mLayoutId, parent, false); return new ViewHolder(view); }
From source file:android.support.test.testapp.SimplePagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { LayoutInflater inflater = LayoutInflater.from(container.getContext()); View view = inflater.inflate(R.layout.pager_view, null); ((TextView) view.findViewById(R.id.pager_content)).setText("Position #" + position); view.setBackgroundColor(COLORS[position]); container.addView(view);// w w w . j a v a2 s .c o m return view; }
From source file:com.pguardiola.HexAdapter.java
@Override public HexAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { this.context = parent.getContext(); Hexagon hexagon = new Hexagon(context); final ViewHolder holder = new ViewHolder(hexagon); hexagon.setOnClickListener(new View.OnClickListener() { @Override//from www .j a v a2 s. c o m public void onClick(View v) { if (listener != null) { listener.onItemClick(v, holder.getAdapterPosition()); } } }); return holder; }