Java Code Examples for android.view.ViewGroup#getContext()
The following examples show how to use
android.view.ViewGroup#getContext() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SearchResultAdapter.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
@Override public SearchResultItemView onCreateViewHolder(ViewGroup parent, int viewType) { final Context context = parent.getContext(); View view = LayoutInflater.from(context) .inflate(viewType, parent, false); switch (viewType) { case SearchResultViewHolder.LAYOUT: { return new SearchResultViewHolder(view, onItemViewClick, query); } case SearchResultAdViewHolder.LAYOUT: { return new SearchResultAdViewHolder(view, onAdClickRelay, oneDecimalFormatter); } default: { return new SearchLoadingViewHolder(view); } } }
Example 2
Source File: ImagePagerAdapter.java From Android-Application-ZJB with Apache License 2.0 | 6 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { Picture picture = mData.get(position); CenterCropImageView imageView = new CenterCropImageView(container.getContext()); int w = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY); int h = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY); imageView.measure(w, h); container.addView(imageView); ZjbImageLoader.create(picture.getUrl()) .setDisplayType(ZjbImageLoader.DISPLAY_FADE_IN) .setQiniu(width, height) .setBitmapConfig(Bitmap.Config.RGB_565) .setFadeInTime(1000) .setDefaultDrawable(new ColorDrawable(0xffe0dedc)) .into(imageView); imageView.setOnClickListener(v -> { if (null != mOnImageClickListener) { mOnImageClickListener.onClick(position); } }); return imageView; }
Example 3
Source File: BaseFetchLoadAdapter.java From NIM_Android_UIKit with MIT License | 6 votes |
@Override public K onCreateViewHolder(ViewGroup parent, int viewType) { K baseViewHolder; this.mContext = parent.getContext(); this.mLayoutInflater = LayoutInflater.from(mContext); switch (viewType) { case FETCHING_VIEW: baseViewHolder = getFetchingView(parent); break; case LOADING_VIEW: baseViewHolder = getLoadingView(parent); break; case EMPTY_VIEW: baseViewHolder = createBaseViewHolder(mEmptyView); break; default: baseViewHolder = onCreateDefViewHolder(parent, viewType); } return baseViewHolder; }
Example 4
Source File: HomeFragment.java From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View homeView = inflater.inflate(R.layout.fragment_home, container, false); // Inflate the layout for this fragment // Extract tweets ArrayList<TweetModel> tweets = QueryUtils.extractTweets(); // Setup Home Page Feed Adapter FeedAdapter adapter = new FeedAdapter(container.getContext(), tweets); //Setup RecyclerView from layout RecyclerView recyclerView = homeView.findViewById(R.id.recyclerview_feed); recyclerView.setHasFixedSize(true); // Setting up linear layout for Recycler View LinearLayoutManager layoutManager = new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL, false); recyclerView.setAdapter(adapter); recyclerView.setLayoutManager(layoutManager); return homeView; }
Example 5
Source File: AutofillEditorBase.java From delion with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); setHasOptionsMenu(true); mContext = container.getContext(); // We know which profile to edit based on the GUID stuffed in // our extras by AutofillPreferences. Bundle extras = getArguments(); if (extras != null) { mGUID = extras.getString(AutofillPreferences.AUTOFILL_GUID); } if (mGUID == null) { mGUID = ""; mIsNewEntry = true; } else { mIsNewEntry = false; } getActivity().setTitle(getTitleResourceId(mIsNewEntry)); // Hide the top shadow on the ScrollView because the toolbar draws one. FadingEdgeScrollView scrollView = (FadingEdgeScrollView) inflater.inflate( R.layout.autofill_editor_base, container, false); scrollView.setShadowVisibility(false, true); // Inflate the editor and buttons into the "content" LinearLayout. LinearLayout contentLayout = (LinearLayout) scrollView.findViewById(R.id.content); inflater.inflate(getLayoutId(), contentLayout, true); inflater.inflate(R.layout.autofill_editor_base_buttons, contentLayout, true); return scrollView; }
Example 6
Source File: HDividerAdapter.java From expandable-recyclerview with MIT License | 5 votes |
@Override public GroupVH onCreateGroupViewHolder(ViewGroup parent, int viewType) { Log.d(TAG, ">>> onCreateGroupViewHolder: " + viewType); Context context = parent.getContext(); if (viewType == Shop.TYPE_ALL) { return new AllVH(LayoutInflater.from(context).inflate(R.layout.v_item_group_all, parent, false)); } else if (viewType == Shop.TYPE_OFFLINE) { return new OffLineVH(LayoutInflater.from(context).inflate(R.layout.v_item_group_offline, parent, false)); } else { return new OnLineVH(LayoutInflater.from(context).inflate(R.layout.v_item_group_online, parent, false)); } }
Example 7
Source File: StatusAdapterWrapper.java From monero-wallet-android-app with MIT License | 5 votes |
public RecyclerView.ViewHolder createLoadingViewHolder(ViewGroup parent) { FrameLayout frameLayout = new FrameLayout(parent.getContext()); ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); frameLayout.setLayoutParams(lp); ProgressBar progressBar = new ProgressBar(parent.getContext()); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); layoutParams.gravity = Gravity.CENTER; progressBar.setLayoutParams(layoutParams); frameLayout.addView(progressBar); return new StatusViewHolder(frameLayout); }
Example 8
Source File: ClassifyFragment.java From HomeApplianceMall with MIT License | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_classify, container, false); canAC = true; myApplication = (MyApplication)getActivity().getApplication(); listView = (ListView) v.findViewById(R.id.listView_fclass); refreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.refreshLayout_f_class); layoutTv = (LinearLayout) v.findViewById(R.id.linearLayout_f_class_tv); layoutFridge = (LinearLayout) v.findViewById(R.id.linearLayout_f_class_fridge); layoutAir = (LinearLayout) v.findViewById(R.id.linearLayout_f_class_air); layoutGeyser = (LinearLayout) v.findViewById(R.id.linearLayout_f_class_geyser); layoutWasher = (LinearLayout) v.findViewById(R.id.linearLayout_f_class_washer); kindMap = new HashMap<>(); listList = new ArrayList<>(); refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { // 刷新操作 int kind = myApplication.getCurrentKind(); if(kind<0){ kind = -1*kind; updateData(kind+""); } } }); layoutTv.setOnClickListener(this); layoutFridge.setOnClickListener(this); layoutAir.setOnClickListener(this); layoutGeyser.setOnClickListener(this); layoutWasher.setOnClickListener(this); myAdape = new MyAdapterForListGoods(container.getContext(),listList); listView.setAdapter(myAdape); return v; }
Example 9
Source File: VideoDivideActivity.java From PLDroidShortVideo with Apache License 2.0 | 5 votes |
@Override public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { Context context = parent.getContext(); LayoutInflater inflater = LayoutInflater.from(context); View contactView = inflater.inflate(R.layout.item_devide_frame, parent, false); ItemViewHolder viewHolder = new ItemViewHolder(contactView); return viewHolder; }
Example 10
Source File: DialogMenu.java From Dashchan with Apache License 2.0 | 5 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { ListItem listItem = getItem(position); ViewHolder viewHolder; if (convertView == null) { viewHolder = new ViewHolder(); View view = LayoutInflater.from(parent.getContext()).inflate(layoutResId, parent, false); if (listItem.checkable) { LinearLayout linearLayout = new LinearLayout(parent.getContext()); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.setGravity(Gravity.CENTER_VERTICAL); linearLayout.addView(view, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f)); CheckBox checkBox = new CheckBox(parent.getContext()); checkBox.setClickable(false); checkBox.setFocusable(false); int paddingRight = view.getPaddingRight() - (int) (4f * ResourceUtils.obtainDensity(view)); checkBox.setPadding(checkBox.getPaddingLeft(), checkBox.getPaddingTop(), Math.max(checkBox.getPaddingRight(), paddingRight), checkBox.getPaddingBottom()); linearLayout.addView(checkBox, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); viewHolder.checkBox = checkBox; view = linearLayout; } viewHolder.textView = view.findViewById(android.R.id.text1); view.setTag(viewHolder); convertView = view; } else { viewHolder = (ViewHolder) convertView.getTag(); } viewHolder.textView.setText(listItem.title); if (listItem.checkable) { viewHolder.checkBox.setChecked(listItem.checked); } return convertView; }
Example 11
Source File: ColorizeFaceActivity.java From FaceT with Mozilla Public License 2.0 | 5 votes |
@Override public ProductViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { Context context = parent.getContext(); View view = getLayoutInflater().inflate(R.layout.makeup_product_row, parent, false); ProductViewHolder viewHolder = new ProductViewHolder(view); return viewHolder; }
Example 12
Source File: ViewHolder.java From ProjectX with Apache License 2.0 | 5 votes |
ViewHolder(ViewGroup parent) { super(new AppCompatTextView(parent.getContext())); mVText = (AppCompatTextView) itemView; mVText.setGravity(Gravity.CENTER); mVText.setBackgroundColor(0xff00dd00); mVText.setTextColor(0xffffffff); }
Example 13
Source File: ColorFocusBorder.java From AndroidTvDemo with Apache License 2.0 | 5 votes |
@Override public FocusBorder build(ViewGroup parent) { if (null == parent) { throw new NullPointerException("The FocusBorder parent cannot be null"); } final ColorFocusBorder boriderView = new ColorFocusBorder(parent.getContext(), mShimmerColor, mShimmerDuration, mIsShimmerAnim, mAnimDuration, mPaddingOfsetRectF, mShadowColor, mShadowWidth, mBorderColor, mBorderWidth); final ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(1, 1); parent.addView(boriderView, lp); return boriderView; }
Example 14
Source File: GreenAdapter.java From android-dev-challenge with Apache License 2.0 | 5 votes |
/** * * This gets called when each new ViewHolder is created. This happens when the RecyclerView * is laid out. Enough ViewHolders will be created to fill the screen and allow for scrolling. * * @param viewGroup The ViewGroup that these ViewHolders are contained within. * @param viewType If your RecyclerView has more than one type of item (which ours doesn't) you * can use this viewType integer to provide a different layout. See * {@link android.support.v7.widget.RecyclerView.Adapter#getItemViewType(int)} * for more details. * @return A new NumberViewHolder that holds the View for each list item */ @Override public NumberViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { Context context = viewGroup.getContext(); int layoutIdForListItem = R.layout.number_list_item; LayoutInflater inflater = LayoutInflater.from(context); boolean shouldAttachToParentImmediately = false; View view = inflater.inflate(layoutIdForListItem, viewGroup, shouldAttachToParentImmediately); NumberViewHolder viewHolder = new NumberViewHolder(view); return viewHolder; }
Example 15
Source File: FollowList.java From ShareSDKShareDifMsgDemo-Android with MIT License | 4 votes |
public View getView(int position, View convertView, ViewGroup parent) { FollowListItem item = null; if (convertView == null) { LinearLayout llItem = new LinearLayout(parent.getContext()); item = new FollowListItem(); llItem.setTag(item); convertView = llItem; item.aivIcon = new AsyncImageView(getContext()); int dp_52 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 52); int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(parent.getContext(), 10); int dp_5 = cn.sharesdk.framework.utils.R.dipToPx(parent.getContext(), 5); LinearLayout.LayoutParams lpIcon = new LinearLayout.LayoutParams(dp_52, dp_52); lpIcon.gravity = Gravity.CENTER_VERTICAL; lpIcon.setMargins(dp_10, dp_5, dp_10, dp_5); item.aivIcon.setLayoutParams(lpIcon); llItem.addView(item.aivIcon); LinearLayout llText = new LinearLayout(parent.getContext()); llText.setPadding(0, dp_10, dp_10, dp_10); llText.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams lpText = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lpText.gravity = Gravity.CENTER_VERTICAL; lpText.weight = 1; llText.setLayoutParams(lpText); llItem.addView(llText); item.tvName = new TextView(parent.getContext()); item.tvName.setTextColor(0xff000000); item.tvName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); item.tvName.setSingleLine(); llText.addView(item.tvName); item.tvSign = new TextView(parent.getContext()); item.tvSign.setTextColor(0x7f000000); item.tvSign.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); item.tvSign.setSingleLine(); llText.addView(item.tvSign); item.ivCheck = new ImageView(parent.getContext()); item.ivCheck.setPadding(0, 0, dp_10, 0); LinearLayout.LayoutParams lpCheck = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lpCheck.gravity = Gravity.CENTER_VERTICAL; item.ivCheck.setLayoutParams(lpCheck); llItem.addView(item.ivCheck); } else { item = (FollowListItem) convertView.getTag(); } Following following = getItem(position); item.tvName.setText(following.screeName); item.tvSign.setText(following.description); item.ivCheck.setImageBitmap(following.checked ? bmChd : bmUnch); if (isFling()) { Bitmap bm = BitmapProcessor.getBitmapFromCache(following.icon); if (bm != null && !bm.isRecycled()) { item.aivIcon.setImageBitmap(bm); } else { item.aivIcon.execute(null, AsyncImageView.DEFAULT_TRANSPARENT); } } else { item.aivIcon.execute(following.icon); } if (position == getCount() - 1) { next(); } return convertView; }
Example 16
Source File: SimpleStringAdapter.java From rv-adapter-states with MIT License | 4 votes |
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { return new ItemViewHolder(new TextView(parent.getContext())); }
Example 17
Source File: SeekBarCardView.java From KA27 with Apache License 2.0 | 4 votes |
@Override public View getView(ViewGroup viewGroup) { return new SeekBarCardView(viewGroup.getContext(), list); }
Example 18
Source File: NarrowImageAdapter.java From YCRefreshView with Apache License 2.0 | 4 votes |
public NarrowImageViewHolder(ViewGroup parent) { super(new ImageView(parent.getContext())); imgPicture = (ImageView) itemView; imgPicture.setLayoutParams(new ViewGroup.LayoutParams((int) AppUtils.convertDpToPixel(72f,getContext()), ViewGroup.LayoutParams.MATCH_PARENT)); imgPicture.setScaleType(ImageView.ScaleType.CENTER_CROP); }
Example 19
Source File: CaptureListAdapter.java From CapturePacket with MIT License | 4 votes |
@NonNull @Override public CaptureEntryViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { return new CaptureEntryViewHolder(parent.getContext(),mEntryTabDelegate); }
Example 20
Source File: VanillaAdapter.java From UniversalAdapter with Apache License 2.0 | 4 votes |
@Override protected VanillaHolder onCreateViewHolder(ViewGroup parent, int itemType) { return new VanillaHolder(new View(parent.getContext())); }