本文整理匯總了Java中android.view.ViewStub類的典型用法代碼示例。如果您正苦於以下問題:Java ViewStub類的具體用法?Java ViewStub怎麽用?Java ViewStub使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ViewStub類屬於android.view包,在下文中一共展示了ViewStub類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import android.view.ViewStub; //導入依賴的package包/類
@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();
}
}
});
}
示例2: setProgressBarShown
import android.view.ViewStub; //導入依賴的package包/類
/**
* 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);
}
}
}
示例3: loadData
import android.view.ViewStub; //導入依賴的package包/類
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);
}
});
}
示例4: findViewFromViewStub
import android.view.ViewStub; //導入依賴的package包/類
/**
* 把 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;
}
示例5: createGraphObjectView
import android.view.ViewStub; //導入依賴的package包/類
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;
}
示例6: bindEvenListener
import android.view.ViewStub; //導入依賴的package包/類
@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");
}
}
示例7: showStatusView
import android.view.ViewStub; //導入依賴的package包/類
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);
}
}
示例8: onCreate
import android.view.ViewStub; //導入依賴的package包/類
@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();
}
示例9: setSearchProviderHasLogo
import android.view.ViewStub; //導入依賴的package包/類
/**
* 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;
}
示例10: updateMostVisitedPlaceholderVisibility
import android.view.ViewStub; //導入依賴的package包/類
/**
* 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);
}
}
示例11: onFinishInflate
import android.view.ViewStub; //導入依賴的package包/類
@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);
}
}
示例12: showAlternativeView
import android.view.ViewStub; //導入依賴的package包/類
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);
}
示例13: onCreateView
import android.view.ViewStub; //導入依賴的package包/類
@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;
}
示例14: onCreateView
import android.view.ViewStub; //導入依賴的package包/類
@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;
}
示例15: PhotoPostVH
import android.view.ViewStub; //導入依賴的package包/類
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);
}
}