當前位置: 首頁>>代碼示例>>Java>>正文


Java ViewStub類代碼示例

本文整理匯總了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();
            }
        }
    });
}
 
開發者ID:alidili,項目名稱:Demos,代碼行數:25,代碼來源:ViewStubActivity.java

示例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);
        }
    }
}
 
開發者ID:Trumeet,項目名稱:SetupWizardLibCompat,代碼行數:21,代碼來源:SetupWizardLayout.java

示例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);
        }
    });
}
 
開發者ID:liupengandroid,項目名稱:ywApplication,代碼行數:25,代碼來源:HomeFragment.java

示例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;
}
 
開發者ID:coopese,項目名稱:qmui,代碼行數:26,代碼來源:QMUIViewHelper.java

示例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;
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:24,代碼來源:GraphObjectAdapter.java

示例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");
    }
}
 
開發者ID:alphater,項目名稱:garras,代碼行數:23,代碼來源:MainActivity.java

示例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);
    }
}
 
開發者ID:woxingxiao,項目名稱:GracefulMovies,代碼行數:30,代碼來源:MainActivity.java

示例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();
    }
 
開發者ID:DysaniazzZ,項目名稱:ArtOfAndroid,代碼行數:22,代碼來源:MainActivity.java

示例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;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:29,代碼來源:NewTabPageView.java

示例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);
    }
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:27,代碼來源:NewTabPageView.java

示例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);
    }
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:21,代碼來源:SelectableListLayout.java

示例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);
}
 
開發者ID:fekracomputers,項目名稱:IslamicLibraryAndroid,代碼行數:25,代碼來源:DownloadProgressActivity.java

示例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;
}
 
開發者ID:fekracomputers,項目名稱:IslamicLibraryAndroid,代碼行數:17,代碼來源:GlobalUserNotesFragment.java

示例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;
}
 
開發者ID:fekracomputers,項目名稱:IslamicLibraryAndroid,代碼行數:26,代碼來源:BookmarkFragment.java

示例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);
    }
}
 
開發者ID:mingdroid,項目名稱:tumbviewer,代碼行數:25,代碼來源:PhotoPostVH.java


注:本文中的android.view.ViewStub類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。