Java Code Examples for android.view.ViewGroup#setEnabled()

The following examples show how to use android.view.ViewGroup#setEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: X8CameraOtherSettingController.java    From FimiX8-RE with MIT License 6 votes vote down vote up
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);
                }
            }
        }
    }
}
 
Example 2
Source File: UIUtils.java    From sensordatacollector with GNU General Public License v2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example 3
Source File: PreferenceFragment.java    From Jockey with Apache License 2.0 5 votes vote down vote up
@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);
                }
            }
        }
    };
}
 
Example 4
Source File: DiscussionUtils.java    From edx-app-android with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 5
Source File: AbstractValidateableView.java    From AndroidMaterialValidation with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example 6
Source File: CollectActivity.java    From Field-Book with GNU General Public License v2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example 7
Source File: CollectActivity.java    From Field-Book with GNU General Public License v2.0 5 votes vote down vote up
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);
        }
    }
}