本文整理汇总了Java中android.view.ViewGroup.setVisibility方法的典型用法代码示例。如果您正苦于以下问题:Java ViewGroup.setVisibility方法的具体用法?Java ViewGroup.setVisibility怎么用?Java ViewGroup.setVisibility使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.ViewGroup
的用法示例。
在下文中一共展示了ViewGroup.setVisibility方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initEventAndData
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
protected void initEventAndData() {
viewMain = (ViewGroup) findViewById(R.id.view_main);
if (viewMain == null) {
throw new IllegalStateException(
"The subclass of RootActivity must contain a View named 'view_main'.");
}
if (!(viewMain.getParent() instanceof ViewGroup)) {
throw new IllegalStateException(
"view_main's ParentView should be a ViewGroup.");
}
mParent = (ViewGroup) viewMain.getParent();
View.inflate(mContext, R.layout.view_progress, mParent);
viewLoading = mParent.findViewById(R.id.view_loading);
ivLoading = (ProgressImageView) viewLoading.findViewById(R.id.iv_progress);
viewLoading.setVisibility(View.GONE);
viewMain.setVisibility(View.VISIBLE);
}
示例2: setupContent
import android.view.ViewGroup; //导入方法依赖的package包/类
private void setupContent(ViewGroup contentPanel) {
this.mScrollView = (NestedScrollView) this.mWindow.findViewById(R.id.scrollView);
this.mScrollView.setFocusable(false);
this.mScrollView.setNestedScrollingEnabled(false);
this.mMessageView = (TextView) contentPanel.findViewById(16908299);
if (this.mMessageView != null) {
if (this.mMessage != null) {
this.mMessageView.setText(this.mMessage);
return;
}
this.mMessageView.setVisibility(8);
this.mScrollView.removeView(this.mMessageView);
if (this.mListView != null) {
ViewGroup scrollParent = (ViewGroup) this.mScrollView.getParent();
int childIndex = scrollParent.indexOfChild(this.mScrollView);
scrollParent.removeViewAt(childIndex);
scrollParent.addView(this.mListView, childIndex, new LayoutParams(-1, -1));
return;
}
contentPanel.setVisibility(8);
}
}
示例3: invalidateDisplayListInt
import android.view.ViewGroup; //导入方法依赖的package包/类
private void invalidateDisplayListInt(ViewGroup viewGroup, boolean invalidateThis) {
for (int i = viewGroup.getChildCount() - 1; i >= 0; i--) {
View view = viewGroup.getChildAt(i);
if (view instanceof ViewGroup) {
invalidateDisplayListInt((ViewGroup) view, true);
}
}
if (!invalidateThis) {
return;
}
if (viewGroup.getVisibility() == 4) {
viewGroup.setVisibility(0);
viewGroup.setVisibility(4);
return;
}
int visibility = viewGroup.getVisibility();
viewGroup.setVisibility(4);
viewGroup.setVisibility(visibility);
}
示例4: addBannerAds
import android.view.ViewGroup; //导入方法依赖的package包/类
@Nullable
public static PublisherAdView addBannerAds(Context context, @Nullable ViewGroup container, AdSize... adSizes) {
if (isPremiumUser(context)) {
if (container != null) {
container.setVisibility(View.GONE);
}
return null;
} else {
if (container == null) return null;
container.setVisibility(View.VISIBLE);
PublisherAdView publisherAdView = new PublisherAdView(context);
publisherAdView.setAdSizes(adSizes);
publisherAdView.setAdUnitId(AdConstants.AdUnitId.AD_UNIT_ID_NATIVE_MAIN_320_50);
PublisherAdRequest.Builder builder = new PublisherAdRequest.Builder();
if (BuildConfig.DEBUG) builder.addTestDevice(TEST_DEVICE_ID);
publisherAdView.loadAd(builder.build());
container.removeAllViews();
container.addView(publisherAdView);
return publisherAdView;
}
}
示例5: showCustomView
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
@Deprecated
public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
// This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
LOG.d(TAG, "showing Custom View");
// if a view already exists then immediately terminate the new one
if (mCustomView != null) {
callback.onCustomViewHidden();
return;
}
// Store the view and its callback for later (to kill it properly)
mCustomView = view;
mCustomViewCallback = callback;
// Add the custom view to its container.
ViewGroup parent = (ViewGroup) engine.getView().getParent();
parent.addView(view, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
Gravity.CENTER));
// Hide the content view.
engine.getView().setVisibility(View.GONE);
// Finally show the custom view container.
parent.setVisibility(View.VISIBLE);
parent.bringToFront();
}
示例6: onCreateView
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
protected View onCreateView(ViewGroup parent) {
LayoutInflater layoutInflater =
(LayoutInflater) getContext().getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = layoutInflater.inflate(R.layout.mp_preference, parent, false);
ViewGroup widgetFrame = (ViewGroup) layout.findViewById(R.id.widget_frame);
int widgetLayoutResId = getWidgetLayoutResource();
if (widgetLayoutResId != 0) {
layoutInflater.inflate(widgetLayoutResId, widgetFrame);
}
widgetFrame.setVisibility(widgetLayoutResId != 0 ? VISIBLE : GONE);
return layout;
}
示例7: displayVoiceMessages
import android.view.ViewGroup; //导入方法依赖的package包/类
private void displayVoiceMessages(final ArrayList<VoiceMessage> voices, ViewGroup container) {
if(Objects.isNull(container)) return;
boolean empty = safeIsEmpty(voices);
container.setVisibility(empty ? View.GONE : View.VISIBLE);
if (empty) {
return;
}
int i = voices.size() - container.getChildCount();
for (int j = 0; j < i; j++) {
container.addView(LayoutInflater.from(mContext).inflate(R.layout.item_voice_message, container, false));
}
for (int g = 0; g < container.getChildCount(); g++) {
ViewGroup root = (ViewGroup) container.getChildAt(g);
if (g < voices.size()) {
VoiceHolder holder = (VoiceHolder) root.getTag();
if(holder == null){
holder = new VoiceHolder(root);
root.setTag(holder);
}
final VoiceMessage voice = voices.get(g);
bindVoiceHolder(holder, voice);
root.setVisibility(View.VISIBLE);
} else {
root.setVisibility(View.GONE);
}
}
}
示例8: displayAudios
import android.view.ViewGroup; //导入方法依赖的package包/类
/**
* Отображение аудиозаписей
*
* @param audios аудиозаписи
* @param container контейнер для аудиозаписей
*/
private void displayAudios(final ArrayList<Audio> audios, ViewGroup container) {
container.setVisibility(safeIsEmpty(audios) ? View.GONE : View.VISIBLE);
if (safeIsEmpty(audios)) {
return;
}
int i = audios.size() - container.getChildCount();
for (int j = 0; j < i; j++) {
container.addView(LayoutInflater.from(mContext).inflate(R.layout.item_small_audio, container, false));
}
for (int g = 0; g < container.getChildCount(); g++) {
ViewGroup root = (ViewGroup) container.getChildAt(g);
if (g < audios.size()) {
final Audio audio = audios.get(g);
AudioHolder holder = new AudioHolder(mContext, root);
holder.tvTitle.setText(audio.getArtist());
holder.tvSubtitle.setText(audio.getTitle());
int finalG = g;
holder.ibPlay.setOnClickListener(v -> mAttachmentsActionCallback.onAudioPlay(finalG, audios));
root.setVisibility(View.VISIBLE);
root.setTag(audio);
} else {
root.setVisibility(View.GONE);
root.setTag(null);
}
}
}
示例9: setupButtons
import android.view.ViewGroup; //导入方法依赖的package包/类
private void setupButtons(ViewGroup buttonPanel) {
boolean hasButtons = false;
int whichButtons = 0;
this.mButtonPositive = (Button) buttonPanel.findViewById(16908313);
this.mButtonPositive.setOnClickListener(this.mButtonHandler);
if (TextUtils.isEmpty(this.mButtonPositiveText)) {
this.mButtonPositive.setVisibility(8);
} else {
this.mButtonPositive.setText(this.mButtonPositiveText);
this.mButtonPositive.setVisibility(0);
whichButtons = 0 | 1;
}
this.mButtonNegative = (Button) buttonPanel.findViewById(16908314);
this.mButtonNegative.setOnClickListener(this.mButtonHandler);
if (TextUtils.isEmpty(this.mButtonNegativeText)) {
this.mButtonNegative.setVisibility(8);
} else {
this.mButtonNegative.setText(this.mButtonNegativeText);
this.mButtonNegative.setVisibility(0);
whichButtons |= 2;
}
this.mButtonNeutral = (Button) buttonPanel.findViewById(16908315);
this.mButtonNeutral.setOnClickListener(this.mButtonHandler);
if (TextUtils.isEmpty(this.mButtonNeutralText)) {
this.mButtonNeutral.setVisibility(8);
} else {
this.mButtonNeutral.setText(this.mButtonNeutralText);
this.mButtonNeutral.setVisibility(0);
whichButtons |= 4;
}
if (whichButtons != 0) {
hasButtons = true;
}
if (!hasButtons) {
buttonPanel.setVisibility(8);
}
}
示例10: reuseView
import android.view.ViewGroup; //导入方法依赖的package包/类
private void reuseView(ViewGroup view) {
if (view == null) {
return;
}
int tag = (Integer)view.getTag();
view.setVisibility(View.GONE);
if (tag == 1) {
textViews.add(view);
} else if (tag == 2) {
imageViews.add(view);
} else if (tag == 3) {
audioViews.add(view);
}
}
示例11: displayForwards
import android.view.ViewGroup; //导入方法依赖的package包/类
public void displayForwards(List<Message> fwds, final ViewGroup fwdContainer, final Context context, boolean postsAsLinks) {
fwdContainer.setVisibility(safeIsEmpty(fwds) ? View.GONE : View.VISIBLE);
if (safeIsEmpty(fwds)) {
return;
}
final int i = fwds.size() - fwdContainer.getChildCount();
for (int j = 0; j < i; j++) {
View localView = LayoutInflater.from(context).inflate(R.layout.item_forward_message, fwdContainer, false);
fwdContainer.addView(localView);
}
for (int g = 0; g < fwdContainer.getChildCount(); g++) {
final ViewGroup itemView = (ViewGroup) fwdContainer.getChildAt(g);
if (g < fwds.size()) {
final Message message = fwds.get(g);
itemView.setVisibility(View.VISIBLE);
itemView.setTag(message);
TextView tvBody = itemView.findViewById(R.id.item_fwd_message_text);
tvBody.setText(message.getBody());
tvBody.setVisibility(message.getBody() == null || message.getBody().length() == 0 ? View.GONE : View.VISIBLE);
((TextView) itemView.findViewById(R.id.item_fwd_message_username)).setText(message.getSender().getFullName());
((TextView) itemView.findViewById(R.id.item_fwd_message_time)).setText(AppTextUtils.getDateFromUnixTime(message.getDate()));
TextView tvFwds = itemView.findViewById(R.id.item_forward_message_fwds);
tvFwds.setVisibility(message.getForwardMessagesCount() > 0 ? View.VISIBLE : View.GONE);
tvFwds.setOnClickListener(v -> mAttachmentsActionCallback.onForwardMessagesOpen(message.getFwd()));
final ImageView ivAvatar = itemView.findViewById(R.id.item_fwd_message_avatar);
String senderPhotoUrl = message.getSender() == null ? null : message.getSender().getMaxSquareAvatar();
ViewUtils.displayAvatar(ivAvatar, mAvatarTransformation, senderPhotoUrl, Constants.PICASSO_TAG);
ivAvatar.setOnClickListener(v -> mAttachmentsActionCallback.onOpenOwner(message.getSenderId()));
AttachmentsHolder attachmentContainers = new AttachmentsHolder();
attachmentContainers.setVgAudios(itemView.findViewById(R.id.audio_attachments)).
setVgDocs(itemView.findViewById(R.id.docs_attachments)).
setVgPhotos(itemView.findViewById(R.id.photo_attachments)).
setVgPosts(itemView.findViewById(R.id.posts_attachments)).
setVgStickers(itemView.findViewById(R.id.stickers_attachments)).
setVoiceMessageRoot(itemView.findViewById(R.id.voice_message_attachments));
displayAttachments(message.getAttachments(), attachmentContainers, postsAsLinks);
} else {
itemView.setVisibility(View.GONE);
itemView.setTag(null);
}
}
}
示例12: setupCustomContent
import android.view.ViewGroup; //导入方法依赖的package包/类
private void setupCustomContent(ViewGroup customPanel) {
final View customView;
if (mView != null) {
customView = mView;
} else if (mViewLayoutResId != 0) {
final LayoutInflater inflater = LayoutInflater.from(mContext);
customView = inflater.inflate(mViewLayoutResId, customPanel, false);
} else {
customView = null;
}
if (customView != null && mViewRoot == null) {
if (mViewRootId != 0) {
mViewRoot = customView.findViewById(mViewRootId);
if (mViewRoot == null) {
throw new NullPointerException("Unable to find root view for the supplied id "
+ mViewRootId + ".");
}
}
}
final boolean hasCustomView = customView != null;
if (!hasCustomView || !canTextInput(customView)) {
mWindow.setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
}
if (hasCustomView) {
final FrameLayout custom = (FrameLayout) mWindow.findViewById(R.id.custom);
custom.addView(customView, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
if (mViewSpacingSpecified) {
custom.setPadding(
mViewSpacingLeft, mViewSpacingTop, mViewSpacingRight, mViewSpacingBottom);
}
if (mListView != null) {
((LinearLayout.LayoutParams) customPanel.getLayoutParams()).weight = 0;
}
} else {
customPanel.setVisibility(View.GONE);
}
}
示例13: setupButtons
import android.view.ViewGroup; //导入方法依赖的package包/类
protected void setupButtons() {
int BIT_BUTTON_POSITIVE = 1;
int BIT_BUTTON_NEGATIVE = 2;
int BIT_BUTTON_NEUTRAL = 4;
int whichButtons = 0;
ViewGroup buttonPanel = getWindow().findViewById(R.id.mongol_dialog_button_panel);
mButtonPositive = buttonPanel.findViewById(R.id.mongol_dialog_button_positive);
mButtonPositive.setOnClickListener(mButtonHandler);
if (TextUtils.isEmpty(mButtonPositiveText)) {
mButtonPositive.setVisibility(View.GONE);
} else {
mButtonPositive.setText(mButtonPositiveText);
mButtonPositive.setVisibility(View.VISIBLE);
whichButtons = whichButtons | BIT_BUTTON_POSITIVE;
}
mButtonNegative = buttonPanel.findViewById(R.id.mongol_dialog_button_negative);
mButtonNegative.setOnClickListener(mButtonHandler);
if (TextUtils.isEmpty(mButtonNegativeText)) {
mButtonNegative.setVisibility(View.GONE);
} else {
mButtonNegative.setText(mButtonNegativeText);
mButtonNegative.setVisibility(View.VISIBLE);
whichButtons = whichButtons | BIT_BUTTON_NEGATIVE;
}
mButtonNeutral = buttonPanel.findViewById(R.id.mongol_dialog_button_neutral);
mButtonNeutral.setOnClickListener(mButtonHandler);
if (TextUtils.isEmpty(mButtonNeutralText)) {
mButtonNeutral.setVisibility(View.GONE);
} else {
mButtonNeutral.setText(mButtonNeutralText);
mButtonNeutral.setVisibility(View.VISIBLE);
whichButtons = whichButtons | BIT_BUTTON_NEUTRAL;
}
final boolean hasButtons = whichButtons != 0;
if (!hasButtons) {
buttonPanel.setVisibility(View.GONE);
}
}
示例14: hideBannerAds
import android.view.ViewGroup; //导入方法依赖的package包/类
public static void hideBannerAds(Context context, @Nullable ViewGroup container) {
if (container != null) {
container.setVisibility(View.GONE);
}
}
示例15: showView
import android.view.ViewGroup; //导入方法依赖的package包/类
protected void showView(ViewGroup view) {
for (ViewGroup v : layouts) {
v.setVisibility(View.GONE);
}
view.setVisibility(View.VISIBLE);
}