@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); final ActivityViewStubBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_view_stub); binding.viewStub.setOnInflateListener(new ViewStub.OnInflateListener() { @Override public void onInflate(ViewStub stub, View inflated) { LayoutIncludeBinding viewStubBinding = DataBindingUtil.bind(inflated); User user = new User("容华", "谢后"); viewStubBinding.setUser(user); } }); binding.setClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!binding.viewStub.isInflated()) { binding.viewStub.getViewStub().inflate(); } } }); }
/** * Sets whether the progress bar below the header text is shown or not. The progress bar is * a lazily inflated ViewStub, which means the progress bar will not actually be part of the * view hierarchy until the first time this is set to {@code true}. */ public void setProgressBarShown(boolean shown) { final View progressBar = findManagedViewById(R.id.suw_layout_progress); if (progressBar != null) { progressBar.setVisibility(shown ? View.VISIBLE : View.GONE); } else if (shown) { final ViewStub progressBarStub = (ViewStub) findManagedViewById(R.id.suw_layout_progress_stub); if (progressBarStub != null) { progressBarStub.inflate(); } if (mProgressBarColor != null) { setProgressBarColor(mProgressBarColor); } } }
private void loadData(String url) { httpUtils = new HttpUtils(); httpUtils.send(HttpRequest.HttpMethod.POST, url, new RequestCallBack<String>() { @Override public void onSuccess(ResponseInfo<String> responseInfo) { String json = responseInfo.result; homeBean = JSON.parseObject(json, HomeBean.class); List<HomeBean.DataEntity.App_index_recommandEntity> list1 = homeBean.getData().getApp_index_recommand(); if (homeBean != null) { View headView = getHeadView(inflater); ptrlistview.getRefreshableView().addHeaderView(headView); } list.addAll(list1); adapter.notifyDataSetChanged(); } @Override public void onFailure(HttpException e, String s) { Toast.makeText(getActivity(), "加载数据失败", Toast.LENGTH_SHORT).show(); View view = ViewStub.inflate(getActivity(),R.layout.faild_layout,null); } }); }
/** * 把 ViewStub inflate 之后在其中根据 id 找 View * * @param parentView 包含 ViewStub 的 View * @param viewStubId 要从哪个 ViewStub 来 inflate * @param inflatedViewId 最终要找到的 View 的 id * @return id 为 inflatedViewId 的 View */ public static View findViewFromViewStub(View parentView, int viewStubId, int inflatedViewId) { if (null == parentView) { return null; } View view = parentView.findViewById(inflatedViewId); if (null == view) { ViewStub vs = (ViewStub) parentView.findViewById(viewStubId); if (null == vs) { return null; } view = vs.inflate(); if (null != view) { view = view.findViewById(inflatedViewId); } } return view; }
/** * @param parentView * @param viewStubId * @param inflatedViewId * @param inflateLayoutResId * @return */ public static View findViewFromViewStub(View parentView, int viewStubId, int inflatedViewId, int inflateLayoutResId) { if (null == parentView) { return null; } View view = parentView.findViewById(inflatedViewId); if (null == view) { ViewStub vs = (ViewStub) parentView.findViewById(viewStubId); if (null == vs) { return null; } if (vs.getLayoutResource() < 1 && inflateLayoutResId > 0) { vs.setLayoutResource(inflateLayoutResId); } view = vs.inflate(); if (null != view) { view = view.findViewById(inflatedViewId); } } return view; }
protected View createGraphObjectView(T graphObject) { View result = inflater.inflate(getGraphObjectRowLayoutId(graphObject), null); ViewStub checkboxStub = (ViewStub) result.findViewById(R.id.com_facebook_picker_checkbox_stub); if (checkboxStub != null) { if (!getShowCheckbox()) { checkboxStub.setVisibility(View.GONE); } else { CheckBox checkBox = (CheckBox) checkboxStub.inflate(); updateCheckboxState(checkBox, false); } } ViewStub profilePicStub = (ViewStub) result.findViewById(R.id.com_facebook_picker_profile_pic_stub); if (!getShowPicture()) { profilePicStub.setVisibility(View.GONE); } else { ImageView imageView = (ImageView) profilePicStub.inflate(); imageView.setVisibility(View.VISIBLE); } return result; }
@Override protected void bindEvenListener(Bundle savedInstanceState) { supportUI(); super.bindEvenListener(savedInstanceState); LocaleUtils.loadLocale(this); FragmentMaster fragmentMaster = getFragmentMaster(); fragmentMaster.registerFragmentLifecycleCallbacks(mLifecycleCallbacks); fragmentMaster.install(R.id.container, new Request(NavigationFragment.class)); int flag = CalendarUtils.festivalFlag(); if (2 == flag) { ViewStub viewStub = findViewById(R.id.view_stub); if (null != viewStub) { viewStub.inflate(); } } if (Hawk.get("WHATS_NEW_VERSION", -1) != BuildConfig.VERSION_CODE) { new ChangelogBottomSheetDialog().show(getSupportFragmentManager(), "ChangelogBottomSheetDialog"); } }
private void showStatusView(boolean loading) { if (mStatusView == null) { mStatusView = ((ViewStub) findViewById(R.id.view_stub)).inflate(); mStatusLoadingImg = (ImageView) mStatusView.findViewById(R.id.status_loading_img); mStatusReloadBtn = (Button) mStatusView.findViewById(R.id.status_reload_button); mStatusNoDataImg = (ImageView) mStatusView.findViewById(R.id.status_no_data_img); mStatusReloadBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showStatusView(true); getPresenter().loadMovieData(); } }); } if (loading) { Animation animation = AnimationUtils.loadAnimation(this, R.anim.anim_rotate); animation.setInterpolator(new LinearInterpolator()); mStatusLoadingImg.setAnimation(animation); mStatusLoadingImg.setVisibility(View.VISIBLE); mStatusReloadBtn.setVisibility(View.INVISIBLE); mStatusNoDataImg.setVisibility(View.INVISIBLE); } else { mStatusLoadingImg.clearAnimation(); mStatusLoadingImg.setVisibility(View.INVISIBLE); mStatusReloadBtn.setVisibility(View.VISIBLE); mStatusNoDataImg.setVisibility(View.VISIBLE); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // findViewById(R.id.root_layout).setBackgroundColor(getResources().getColor(R.color.colorAccent)); findViewById(R.id.include_layout).setBackgroundColor(getResources().getColor(R.color.colorAccent)); //加载ViewStub的两种方式 // findViewById(R.id.viewstub_layout).setVisibility(View.VISIBLE); View inflateView = ((ViewStub)findViewById(R.id.viewstub_layout)).inflate(); new Thread(new Runnable() { @Override public void run() { testANR(); } }).start(); SystemClock.sleep(100); initView(); }
/** * Changes the layout depending on whether the selected search provider (e.g. Google, Bing) * has a logo. * @param hasLogo Whether the search provider has a logo. */ public void setSearchProviderHasLogo(boolean hasLogo) { if (hasLogo == mSearchProviderHasLogo) return; mSearchProviderHasLogo = hasLogo; mMostVisitedDesign.setSearchProviderHasLogo(mMostVisitedLayout, hasLogo); // Hide or show all the views above the Most Visited items. int visibility = hasLogo ? View.VISIBLE : View.GONE; int childCount = mNewTabPageLayout.getChildCount(); for (int i = 0; i < childCount; i++) { View child = mNewTabPageLayout.getChildAt(i); if (child == mMostVisitedLayout) break; // Don't change the visibility of a ViewStub as that will automagically inflate it. if (child instanceof ViewStub) continue; child.setVisibility(visibility); } updateMostVisitedPlaceholderVisibility(); onUrlFocusAnimationChanged(); mSnapshotMostVisitedChanged = true; }
/** * Shows the most visited placeholder ("Nothing to see here") if there are no most visited * items and there is no search provider logo. */ private void updateMostVisitedPlaceholderVisibility() { boolean showPlaceholder = mHasReceivedMostVisitedSites && mMostVisitedLayout.getChildCount() == 0 && !mSearchProviderHasLogo; mNoSearchLogoSpacer.setVisibility( (mSearchProviderHasLogo || showPlaceholder) ? View.GONE : View.INVISIBLE); if (showPlaceholder) { if (mMostVisitedPlaceholder == null) { ViewStub mostVisitedPlaceholderStub = (ViewStub) mNewTabPageLayout .findViewById(R.id.most_visited_placeholder_stub); mMostVisitedPlaceholder = mostVisitedPlaceholderStub.inflate(); } mMostVisitedLayout.setVisibility(GONE); mMostVisitedPlaceholder.setVisibility(VISIBLE); } else if (mMostVisitedPlaceholder != null) { mMostVisitedLayout.setVisibility(VISIBLE); mMostVisitedPlaceholder.setVisibility(GONE); } }
@Override protected void onFinishInflate() { super.onFinishInflate(); LayoutInflater.from(getContext()).inflate(R.layout.selectable_list_layout, this); mEmptyView = (TextView) findViewById(R.id.empty_view); mLoadingView = (LoadingView) findViewById(R.id.loading_view); mLoadingView.showLoadingUI(); mToolbarStub = (ViewStub) findViewById(R.id.action_bar_stub); FadingShadowView shadow = (FadingShadowView) findViewById(R.id.shadow); if (DeviceFormFactor.isLargeTablet(getContext())) { shadow.setVisibility(View.GONE); } else { shadow.init(ApiCompatibilityUtils.getColor(getResources(), R.color.toolbar_shadow_color), FadingShadow.POSITION_TOP); } }
void showAlternativeView(int viewType) { FrameLayout recyclerFrame = findViewById(R.id.recycler_frame); recyclerFrame.setVisibility(View.GONE); mShowCancelAll = false; switch (viewType) { case ZERO_DOWNLOAD_TYPE: ViewStub zeroView = findViewById(R.id.zero_downloads); zeroView.setVisibility(View.VISIBLE); break; case FINISHED_DOWNLOAD_TYPE: ViewStub finishedView = findViewById(R.id.finished_downloads); finishedView.setVisibility(View.VISIBLE); break; case CANCELLED_DOWNLOAD_TYPE: ViewStub cancelledView = findViewById(R.id.cancelled_downloads); cancelledView.setVisibility(View.VISIBLE); break; } new Handler().postDelayed(this::finish, 10000); }
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_global_user_list, container, false); RecyclerView recyclerView = view.findViewById(R.id.recyclerView); ViewStub zeroView = view.findViewById(R.id.zero_global_user_notes); if ((bookmarkItems.isEmpty() && highlightItems.isEmpty())) { recyclerView.setVisibility(View.GONE); zeroView.setVisibility(View.VISIBLE); } else { recyclerView.setAdapter(adapter); } return view; }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_bookmark_list, container, false); // Set the adapter RecyclerView recyclerView = view.findViewById(R.id.recyclerView); ViewStub zeroView = view.findViewById(R.id.zero_bookmarks); UserDataDBHelper userDataDBHelper = UserDataDBHelper.getInstance(getContext(), bookId); ArrayList<Bookmark> bookmarks = userDataDBHelper.getAllBookmarks(UserDataDBContract.BookmarkEntry.COLUMN_NAME_PAGE_ID); if (bookmarks.size() != 0) { recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL)); bookmarkRecyclerViewAdapter = new BookmarkRecyclerViewAdapter(bookmarks, mListener, getContext(), userDataDBHelper, getActivity().getPreferences(Context.MODE_PRIVATE)); bookmarkRecyclerViewAdapter.setHasStableIds(true); recyclerView.setAdapter(bookmarkRecyclerViewAdapter); } else { recyclerView.setVisibility(View.GONE); zeroView.setVisibility(View.VISIBLE); } return view; }
public PhotoPostVH(View itemView) { super(itemView); context = itemView.getContext(); avatarView = (SimpleDraweeView) itemView.findViewById(R.id.post_avatar); nameView = (TextView) itemView.findViewById(R.id.post_name); itemView.findViewById(R.id.post_header).setOnClickListener(this); timeView = (TextView) itemView.findViewById(R.id.post_time); sourceView = (TextView) itemView.findViewById(R.id.post_source); sourceView.setOnClickListener(this); contentLayout = (FlexboxLayout) itemView.findViewById(R.id.post_content); trailLayout = (LinearLayout) itemView.findViewById(R.id.post_trail); noteCountView = (TextView) itemView.findViewById(R.id.note_count); reblogView = (ImageView) itemView.findViewById(R.id.post_reblog); reblogView.setOnClickListener(this); likeView = (ImageView) itemView.findViewById(R.id.post_like); likeView.setOnClickListener(this); dividerWidth = (int) Utils.dp2Pixels(context, 4); deleteStub = (ViewStub) itemView.findViewById(R.id.stub_delete_forever); isSimpleMode = DataManager.getInstance().isSimpleMode(); if (isSimpleMode) { trailLayout.setVisibility(View.GONE); } }
@Nullable private ViewGroup resolvePanel(@Nullable View customPanel, @Nullable View defaultPanel) { if (customPanel == null) { if (defaultPanel instanceof ViewStub) { defaultPanel = ((ViewStub) defaultPanel).inflate(); } return (ViewGroup) defaultPanel; } if (defaultPanel != null) { ViewParent parent = defaultPanel.getParent(); if (parent instanceof ViewGroup) { ((ViewGroup) parent).removeView(defaultPanel); } } if (customPanel instanceof ViewStub) { customPanel = ((ViewStub) customPanel).inflate(); } return (ViewGroup) customPanel; }
@Override public void setContentView(@LayoutRes int layoutResID) { super.setContentView(layoutResID); baseLayout = (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.activity_base, null); setContentView(baseLayout); toolbar = (Toolbar) findViewById(R.id.toolbar); tvToolbarTitle = (TextView) findViewById(R.id.tvToolbarTitle); tvActionButton = (TextView) findViewById(R.id.tvActionButton); tvActionDescription = (TextView) findViewById(R.id.tvActionDescription); tvAbout = (TextView) findViewById(R.id.tvAbout); rlUserAction = (RelativeLayout) findViewById(R.id.rlUserAction); rlContainer = (RelativeLayout) findViewById(R.id.rlContainer); ivToolbarImage = (ImageView) findViewById(R.id.ivToolbarImage); setSupportActionBar(toolbar); ViewStub stub = (ViewStub) baseLayout.findViewById(R.id.container); stub.setLayoutResource(layoutResID); stub.inflate(); ButterKnife.bind(this); }
/** * inflate ViewStub 并返回对应的 View。 */ public static View findViewFromViewStub(View parentView, int viewStubId, int inflatedViewId, int inflateLayoutResId) { if (null == parentView) { return null; } View view = parentView.findViewById(inflatedViewId); if (null == view) { ViewStub vs = (ViewStub) parentView.findViewById(viewStubId); if (null == vs) { return null; } if (vs.getLayoutResource() < 1 && inflateLayoutResId > 0) { vs.setLayoutResource(inflateLayoutResId); } view = vs.inflate(); if (null != view) { view = view.findViewById(inflatedViewId); } } return view; }
public QMUIBottomSheetItemView createItemView(Drawable drawable, CharSequence text, Object tag, int subscriptRes) { LayoutInflater inflater = LayoutInflater.from(mContext); QMUIBottomSheetItemView itemView = (QMUIBottomSheetItemView) inflater.inflate(R.layout.qmui_bottom_sheet_grid_item, null, false); TextView titleTV = (TextView) itemView.findViewById(R.id.grid_item_title); if (mItemTextTypeFace != null) { titleTV.setTypeface(mItemTextTypeFace); } titleTV.setText(text); itemView.setTag(tag); itemView.setOnClickListener(this); AppCompatImageView imageView = (AppCompatImageView) itemView.findViewById(R.id.grid_item_image); imageView.setImageDrawable(drawable); if (subscriptRes != 0) { ViewStub stub = (ViewStub) itemView.findViewById(R.id.grid_item_subscript); View inflated = stub.inflate(); ((ImageView) inflated).setImageResource(subscriptRes); } return itemView; }
private void initView() { mQrCodeFinderView = (ScannerFinderView) findViewById(R.id.qr_code_view_finder); mSurfaceViewStub = (ViewStub) findViewById(R.id.qr_code_view_stub); switch1 = (Switch) findViewById(R.id.switch1); mHasSurface = false; bt = (Button) findViewById(R.id.bt); bt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { bt.setEnabled(false); buildProgressDialog(); CameraManager.get().takeShot(ScannerActivity.this, ScannerActivity.this, ScannerActivity.this); } }); Switch switch2 = (Switch) findViewById(R.id.switch2); switch2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { CameraManager.get().setFlashLight(isChecked); } }); }
@Override protected void onFinishInflate() { super.onFinishInflate(); if (isInEditMode()) { return; } View unlockButton = findViewById(R.id.locked_button); unlockButton.setOnClickListener(this); iCalendarViewStub = (ViewStub) findViewById(R.id.icalendar_stub); }
@Override protected void onFinishInflate() { super.onFinishInflate(); if (isInEditMode()) { return; } View unlockButton = findViewById(R.id.locked_button); unlockButton.setOnClickListener(this); attachmentViewStub = (ViewStub) findViewById(R.id.attachment_stub); }
protected void initViews() { inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.ultimate_recycler_view_layout, this); mRecyclerView = (RecyclerView) view.findViewById(R.id.ultimate_list); mSwipeRefreshLayout = (VerticalSwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_layout); setScrollbars(); mSwipeRefreshLayout.setEnabled(false); if (mRecyclerView != null) { mRecyclerView.setClipToPadding(mClipToPadding); if (mPadding != -1.1f) { mRecyclerView.setPadding(mPadding, mPadding, mPadding, mPadding); } else { mRecyclerView.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom); } } defaultFloatingActionButton = (FloatingActionButton) view.findViewById(R.id.defaultFloatingActionButton); setDefaultScrollListener(); /** * empty view setup */ mEmpty = (ViewStub) view.findViewById(R.id.emptyview); if (mEmptyId != 0) { mEmpty.setLayoutResource(mEmptyId); mEmptyView = mEmpty.inflate(); mEmpty.setVisibility(View.GONE); } /** * floating button setup */ mFloatingButtonViewStub = (ViewStub) view.findViewById(R.id.floatingActionViewStub); mFloatingButtonViewStub.setLayoutResource(mFloatingButtonId); }
@Override protected void initViews() { //super.initViews(); LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.custom_recycler_view_layout, this); mRecyclerView = (RecyclerView) view.findViewById(R.id.ultimate_list); mSwipeRefreshLayout = null; if (mRecyclerView != null) { mRecyclerView.setClipToPadding(mClipToPadding); if (mPadding != -1.1f) { mRecyclerView.setPadding(mPadding, mPadding, mPadding, mPadding); } else { mRecyclerView.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom); } } defaultFloatingActionButton = (FloatingActionButton) view.findViewById(R.id.defaultFloatingActionButton); setDefaultScrollListener(); mEmpty = (ViewStub) view.findViewById(R.id.emptyview); mFloatingButtonViewStub = (ViewStub) view.findViewById(R.id.floatingActionViewStub); mEmpty.setLayoutResource(mEmptyId); mFloatingButtonViewStub.setLayoutResource(mFloatingButtonId); if (mEmptyId != 0) mEmptyView = mEmpty.inflate(); mEmpty.setVisibility(View.GONE); if (mFloatingButtonId != 0) { mFloatingButtonView = mFloatingButtonViewStub.inflate(); mFloatingButtonView.setVisibility(View.VISIBLE); } }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ButterKnife.bind(this, view); ViewStub stub = ButterKnife.findById(view, R.id.stub); stub.inflate(); ViewStub stubWithFontPath = ButterKnife.findById(view, R.id.stub_with_font_path); stubWithFontPath.inflate(); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ButterKnife.bind(this, view); ViewStub stub = ButterKnife.findById(view, R.id.stub); stub.inflate(); ViewStub stubWithFontFamily = ButterKnife.findById(view, R.id.stub_with_font_path); stubWithFontFamily.inflate(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ViewStub stub = (ViewStub) findViewById(R.id.layout_stub); stub.setLayoutResource(R.layout.layout_feedback_form); View inflated = stub.inflate(); initToolbarWithBackButton(); WebView webView = (WebView) findViewById(R.id.webViewAboutProgram); if (BuildConfig.FLAVOR == "free") { switch (Locale.getDefault().getLanguage()) { case "uk": webView.loadUrl("file:///android_asset/about/about_ua_free.html"); break; case "ru": webView.loadUrl("file:///android_asset/about/about_ru_free.html"); break; default: webView.loadUrl("file:///android_asset/about/about_ua_free.html"); break; } } else if (BuildConfig.FLAVOR == "pro") { switch (Locale.getDefault().getLanguage()) { case "uk": webView.loadUrl("file:///android_asset/about/about_ua.html"); break; case "ru": webView.loadUrl("file:///android_asset/about/about_ru.html"); break; default: webView.loadUrl("file:///android_asset/about/about_ua.html"); break; } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); String html = this.getIntent().getStringExtra("html"); lessonName = this.getIntent().getStringExtra("lesson_name"); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setTitle(lessonName); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); } }); ViewStub stub = (ViewStub) findViewById(R.id.layout_stub); stub.setLayoutResource(R.layout.activity_web_view); View inflated = stub.inflate(); String mime = "text/html"; String encoding = "utf-8"; final WebView myWebView = (WebView) findViewById(R.id.webViewArcticle); myWebView.getSettings().setJavaScriptEnabled(true); myWebView.setWebViewClient(webViewClient); myWebView.loadDataWithBaseURL(null, html, mime, encoding, null); }
void initView() { mCardViewPager = (ViewPager) findViewById(R.id.card_view_pager); mBpmTextView = (TextView) findViewById(R.id.bpm_text_view); mTipsTextView = (TextView) findViewById(R.id.tips_text_view); mViewStub = (ViewStub) findViewById(R.id.view_stub); mTimeTextView = (TextView) findViewById(R.id.time_text_view); mDescriptionTextView = (TextView) findViewById(R.id.description_text_view); }
private ViewGroup createGroupWithWeb() { Activity mActivity = this.mActivity; WebParentLayout mFrameLayout = new WebParentLayout(mActivity); mFrameLayout.setId(R.id.web_parent_layout_id); mFrameLayout.setBackgroundColor(Color.WHITE); View target=mIWebLayout==null?(this.mWebView= (WebView) web()):webLayout(); FrameLayout.LayoutParams mLayoutParams = new FrameLayout.LayoutParams(-1, -1); mFrameLayout.addView(target, mLayoutParams); mFrameLayout.bindWebView(this.mWebView); LogUtils.i(TAG, " webView:" + (this.mWebView instanceof AgentWebView)); if(this.mWebView instanceof AgentWebView){ AgentWebConfig.WEBVIEW_TYPE = AgentWebConfig.WEBVIEW_AGENTWEB_SAFE_TYPE; } ViewStub mViewStub=new ViewStub(mActivity); mViewStub.setId(R.id.mainframe_error_viewsub_id); mFrameLayout.addView(mViewStub,new FrameLayout.LayoutParams(-1,-1)); if (isNeedDefaultProgress) { FrameLayout.LayoutParams lp = null; WebProgressBar mWebProgressBar = new WebProgressBar(mActivity); if (height_dp > 0) lp = new FrameLayout.LayoutParams(-2, AgentWebUtils.dp2px(mActivity, height_dp)); else lp = mWebProgressBar.offerLayoutParams(); if (color != -1) mWebProgressBar.setColor(color); lp.gravity = Gravity.TOP; mFrameLayout.addView((View) (this.mBaseProgressSpec = mWebProgressBar), lp); mWebProgressBar.setVisibility(View.GONE); } else if (!isNeedDefaultProgress && progressView != null) { mFrameLayout.addView((View) (this.mBaseProgressSpec = (BaseProgressSpec) progressView), progressView.offerLayoutParams()); progressView.setVisibility(View.GONE); } return mFrameLayout; }
public LinkShareViewHolder(View itemView) { super(itemView); ViewStub viewStub = (ViewStub) itemView.findViewById(R.id.vs_share_fragment_item_main); viewStub.setLayoutResource(R.layout.share_fragment_item_link_layout); viewStub.inflate(); // display = (LinearLayout) viewStub.inflate().findViewById(R.id.ll_share_fragment_item_container); }
public BottomGridSheetBuilder addItem(int imageRes, CharSequence text, Object tag, @Style int style, int subscriptRes) { LayoutInflater inflater = LayoutInflater.from(mContext); // 给机会让用的人自定义ItemView LinearLayout itemView = (LinearLayout) inflater.inflate(R.layout.qmui_bottom_sheet_grid_item, null, false); // 字体加粗 TextView titleTV = (TextView) itemView.findViewById(R.id.grid_item_title); if(mItemTextTypeFace != null){ titleTV.setTypeface(mItemTextTypeFace); } titleTV.setText(text); itemView.setTag(tag); itemView.setOnClickListener(this); AppCompatImageView imageView = (AppCompatImageView) itemView.findViewById(R.id.grid_item_image); imageView.setImageResource(imageRes); if (subscriptRes != 0) { ViewStub stub = (ViewStub) itemView.findViewById(R.id.grid_item_subscript); View inflated = stub.inflate(); ((ImageView) inflated).setImageResource(subscriptRes); } switch (style) { case FIRST_LINE: mFirstLineViews.append(mFirstLineViews.size(), itemView); break; case SECOND_LINE: mSecondLineViews.append(mSecondLineViews.size(), itemView); break; } return this; }
protected void init(Context context, AttributeSet attrs, int defStyleAttr) { LayoutInflater.from(context).inflate(R.layout.qmui_common_list_item, this, true); TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.QMUICommonListItemView, defStyleAttr, 0); @QMUICommonListItemOrientation int orientation = array.getInt(R.styleable.QMUICommonListItemView_qmui_orientation, HORIZONTAL); @QMUICommonListItemAccessoryType int accessoryType = array.getInt(R.styleable.QMUICommonListItemView_qmui_accessory_type, ACCESSORY_TYPE_NONE); final int initTitleColor = array.getColor(R.styleable.QMUICommonListItemView_qmui_commonList_titleColor, QMUIResHelper.getAttrColor(getContext(), R.attr.qmui_config_color_gray_1)); final int initDetailColor = array.getColor(R.styleable.QMUICommonListItemView_qmui_commonList_detailColor, QMUIResHelper.getAttrColor(getContext(), R.attr.qmui_config_color_gray_5)); array.recycle(); mImageView = (ImageView) findViewById(R.id.group_list_item_imageView); mTextContainer = (LinearLayout) findViewById(R.id.group_list_item_textContainer); mTextView = (TextView) findViewById(R.id.group_list_item_textView); mTextView.setTextColor(initTitleColor); mRedDot = (ImageView) findViewById(R.id.group_list_item_tips_dot); mNewTipViewStub = (ViewStub) findViewById(R.id.group_list_item_tips_new); mDetailTextView = (TextView) findViewById(R.id.group_list_item_detailTextView); mDetailTextView.setTextColor(initDetailColor); LinearLayout.LayoutParams detailTextViewLP = (LinearLayout.LayoutParams) mDetailTextView.getLayoutParams(); if (QMUIViewHelper.getIsLastLineSpacingExtraError()) { detailTextViewLP.bottomMargin = -getResources().getDimensionPixelOffset(R.dimen.qmui_list_item_detail_lineSpacingExtra); } if (orientation == VERTICAL) { detailTextViewLP.topMargin = QMUIDisplayHelper.dp2px(getContext(), 6); } else { detailTextViewLP.topMargin = 0; } mAccessoryView = (ViewGroup) findViewById(R.id.group_list_item_accessoryView); setOrientation(orientation); setAccessoryType(accessoryType); }
public boolean setDetailsLayout(int detailsLayoutId) { // Log.d(TAG,"setDetailsLayout "+detailsLayoutId); ViewStub detailsStub = (ViewStub) findViewById(R.id.info_details_stub); if (detailsStub == null) { if(DBG) Log.e(TAG, "setDetailsLayout: detailsStub is null, returning false"); return false; } if (detailsLayoutId == 0) { if(DBG) Log.e(TAG, "setDetailsLayout: detailsLayoutId is zero, returning false"); return false; } // First hide the "processing..." view if (mDetailsProcessingView != null) { mDetailsProcessingView.setVisibility(View.GONE); } // Then inflate the detailled infos if ((detailsStub != null) && (detailsLayoutId != 0)) { detailsStub.setLayoutResource(detailsLayoutId); detailsStub.inflate(); } else { if(DBG) Log.w(TAG, "setDetailsLayout: detailsStub=" + detailsStub + " / " + "detailsLayoutId=" + detailsLayoutId); } return true; }
private void inflateDataUiLayout(){ ViewStub viewStub = (ViewStub) findViewById(R.id.vs_data_ui_layout); if(viewStub == null){ //already inflate return; } View dataUiRoot = viewStub.inflate(); //初始化数据UI相关 mViewGpsPower = dataUiRoot.findViewById(R.id.view_gps_power); mBtnChangeMapUi = (Button) dataUiRoot.findViewById(R.id.btn_change_to_map_ui); mTvDataMoveDistance = (TextView) dataUiRoot.findViewById(R.id.tv_data_ui_distance); mTvDataMoveTime = (TextView) dataUiRoot.findViewById(R.id.tv_data_ui_time); mBtnChangeMapUi.setOnClickListener(this); }
@Override public void onInflate(ViewStub stub, View inflated) { searchScrubBar = (SearchScrubBar) inflated; searchScrubBar.setupPagingDirection(mIsArabic); searchScrubBar.setOnClickListener(view -> { if (view == searchScrubBar.getPreviousButton()) { ReadingActivity.this.moveToPreviousMatch(); } else if (view == searchScrubBar.getNextButton()) { ReadingActivity.this.moveToNextMatch(); } }); searchScrubBar.setExitSearchListener(v -> { if (!isInGlobalSearchResult()) { removeSearchResultFragment(); } exitSearchMode(); }); searchScrubBar.setMatchDescriptionOnClickListener(v -> { if (!isInGlobalSearchResult()) { reShowSearchResultFragment(); } else { //TODO May be change the scenario to remove the Search activity from the application backStack finish(); } }); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_highlight_list, container, false); RecyclerView recyclerView = view.findViewById(R.id.recyclerView); ViewStub zeroView = view.findViewById(R.id.zero_highlights); UserDataDBHelper userDataDBHelper = UserDataDBHelper.getInstance(getContext(), bookId); ArrayList<Highlight> userDataDBHelperAllHighlights = userDataDBHelper.getAllHighlights(); if (userDataDBHelperAllHighlights.size() != 0) { recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL)); highlightRecyclerViewAdapter = new HighlightRecyclerViewAdapter( userDataDBHelperAllHighlights, mListener, getContext().getApplicationContext(), getActivity().getPreferences(Context.MODE_PRIVATE)); highlightRecyclerViewAdapter.setHasStableIds(true); recyclerView.setAdapter(highlightRecyclerViewAdapter); } else { recyclerView.setVisibility(View.GONE); zeroView.setVisibility(View.VISIBLE); } return view; }