android.view.ViewGroup#setEnabled ( )源码实例Demo

下面列出了android.view.ViewGroup#setEnabled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private void updateViewEnable(boolean enable, ViewGroup... parent) {
    if (parent != null && parent.length > 0) {
        for (ViewGroup group : parent) {
            group.setEnabled(enable);
            int len = group.getChildCount();
            for (int j = 0; j < len; j++) {
                View subView = group.getChildAt(j);
                if (subView instanceof ViewGroup) {
                    updateViewEnable(enable, (ViewGroup) subView);
                } else {
                    subView.setEnabled(enable);
                }
            }
        }
    }
}
 
源代码2 项目: sensordatacollector   文件: UIUtils.java
public static void setEnabled(ViewGroup layout, boolean enabled)
{
    layout.setEnabled(false);
    for(int i = 0; i < layout.getChildCount(); i++) {
        View child = layout.getChildAt(i);
        if(child instanceof ViewGroup) {
            setEnabled((ViewGroup) child, enabled);
        } else {
            child.setEnabled(enabled);
        }
    }
}
 
源代码3 项目: Jockey   文件: PreferenceFragment.java
@Override
protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
    return new PreferenceGroupAdapter(preferenceScreen) {
        @Override
        public void onBindViewHolder(PreferenceViewHolder holder, int position) {
            super.onBindViewHolder(holder, position);

            // Override Equalizer preference attachment to add a long click listener
            // and to change the detail text at runtime
            String fragment = getItem(position).getFragment();
            if ("com.marverenic.music.ui.settings.EqualizerFragment".equals(fragment)) {

                ViewGroup itemView = (ViewGroup) holder.itemView;
                TextView title = itemView.findViewById(android.R.id.title);
                TextView detail = itemView.findViewById(android.R.id.summary);

                boolean hasSystemEq = Util.getSystemEqIntent(getContext()) != null;

                if (hasSystemEq && Util.hasEqualizer()) {
                    // If we have Jockey's Equalizer and another Equalizer
                    itemView.setOnLongClickListener(PreferenceFragment.this);
                    detail.setText(R.string.equalizer_more_options_detail);
                    detail.setVisibility(View.VISIBLE);

                } else if (hasSystemEq && !Util.hasEqualizer()) {
                    // If we don't have any equalizers
                    detail.setText(R.string.equalizer_unsupported);
                    detail.setVisibility(View.VISIBLE);
                    itemView.setEnabled(false);
                    title.setEnabled(false);
                    detail.setEnabled(false);
                }
            }
        }
    };
}
 
源代码4 项目: edx-app-android   文件: DiscussionUtils.java
/**
 * Sets the state, text and icon of the new item creation button on discussion screens
 *
 * @param isTopicClosed     Boolean if the topic is closed or not
 * @param textView          The TextView whose text has to be updated
 * @param positiveTextResId The text resource to be applied when topic IS NOT closed
 * @param negativeTextResId The text resource to be applied when topic IS closed
 * @param creationLayout    The layout which should be enabled/disabled and applied listener to
 * @param listener          The listener to apply to creationLayout
 */
public static void setStateOnTopicClosed(boolean isTopicClosed, TextView textView,
                                         @StringRes int positiveTextResId,
                                         @StringRes int negativeTextResId,
                                         ViewGroup creationLayout,
                                         View.OnClickListener listener) {
    Context context = textView.getContext();
    if (isTopicClosed) {
        textView.setText(negativeTextResId);
        TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(textView,
                new IconDrawable(context, FontAwesomeIcons.fa_lock)
                        .sizeRes(context, R.dimen.small_icon_size)
                        .colorRes(context, R.color.white),
                null, null, null
        );
        creationLayout.setOnClickListener(null);
    } else {
        textView.setText(positiveTextResId);
        TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(textView,
                new IconDrawable(context, FontAwesomeIcons.fa_plus_circle)
                        .sizeRes(context, R.dimen.small_icon_size)
                        .colorRes(context, R.color.white),
                null, null, null
        );
        creationLayout.setOnClickListener(listener);
    }
    creationLayout.setEnabled(!isTopicClosed);
}
 
/**
 * Adapts the enable state of all children of a specific view group.
 *
 * @param viewGroup
 *         The view group, whose children's enabled states should be adapted, as an instance of
 *         the class {@link ViewGroup}. The view group may not be null
 * @param enabled
 *         True, if the children should be enabled, false otherwise
 */
private void setEnabledOnViewGroup(@NonNull final ViewGroup viewGroup, final boolean enabled) {
    viewGroup.setEnabled(enabled);

    for (int i = 0; i < viewGroup.getChildCount(); i++) {
        View child = viewGroup.getChildAt(i);

        if (child instanceof ViewGroup) {
            setEnabledOnViewGroup((ViewGroup) child, enabled);
        } else {
            child.setEnabled(enabled);
        }
    }
}
 
源代码6 项目: Field-Book   文件: CollectActivity.java
public static void disableViews(ViewGroup layout) {
    layout.setEnabled(false);
    for (int i = 0; i < layout.getChildCount(); i++) {
        View child = layout.getChildAt(i);
        if (child instanceof ViewGroup) {
            disableViews((ViewGroup) child);
        } else {
            child.setEnabled(false);
        }
    }
}
 
源代码7 项目: Field-Book   文件: CollectActivity.java
public static void enableViews(ViewGroup layout) {
    layout.setEnabled(false);
    for (int i = 0; i < layout.getChildCount(); i++) {
        View child = layout.getChildAt(i);
        if (child instanceof ViewGroup) {
            enableViews((ViewGroup) child);
        } else {
            child.setEnabled(true);
        }
    }
}
 
 方法所在类