Example usage for android.view View setEnabled

List of usage examples for android.view View setEnabled

Introduction

In this page you can find the example usage for android.view View setEnabled.

Prototype

@RemotableViewMethod
public void setEnabled(boolean enabled) 

Source Link

Document

Set the enabled state of this view.

Usage

From source file:com.example.rps.RpsFragment.java

private void enableViews(boolean enabled, View... views) {
    for (View view : views) {
        view.setEnabled(enabled);
    }//from ww w .j  ava2 s.c o  m
}

From source file:com.silentcircle.contacts.editor.RawContactEditorView.java

@Override
public void setEnabled(boolean enabled) {
    super.setEnabled(enabled);

    View view = getPhotoEditor();
    if (view != null) {
        view.setEnabled(enabled);
    }/*from   ww  w  .j a v  a2s  . co  m*/

    if (mName != null) {
        mName.setEnabled(enabled);
    }

    if (mPhoneticName != null) {
        mPhoneticName.setEnabled(enabled);
    }

    if (mFields != null) {
        int count = mFields.getChildCount();
        for (int i = 0; i < count; i++) {
            mFields.getChildAt(i).setEnabled(enabled);
        }
    }

    if (mGroupMembershipView != null) {
        mGroupMembershipView.setEnabled(enabled);
    }

    mAddFieldButton.setEnabled(enabled);
}

From source file:com.android.deskclock.RingtonePickerDialogFragment.java

@Override
public void onLoadFinished(Loader<RingtoneManager> loader, RingtoneManager ringtoneManager) {
    // Swap in the new ringtone manager.
    mRingtoneAdapter.setRingtoneManager(ringtoneManager);

    // Preserve the selected ringtone.
    final ListView listView = mDialog.getListView();
    final int checkedPosition = mRingtoneAdapter.getRingtonePosition(mSelectedRingtoneUri);
    if (checkedPosition != ListView.INVALID_POSITION) {
        listView.setItemChecked(checkedPosition, true);

        // Also scroll the list to the selected ringtone (this method is poorly named).
        listView.setSelection(checkedPosition);
    } else {//www .  ja  va 2s .  co  m
        // Can't find the selected ringtone, clear the current selection.
        mSelectedRingtoneUri = null;
        listView.clearChoices();
    }

    // Enable the positive button if we have a valid selection (Note: the positive button may
    // be null if this callback returns before onStart).
    final View positiveButton = mDialog.getButton(DialogInterface.BUTTON_POSITIVE);
    if (positiveButton != null) {
        positiveButton.setEnabled(mSelectedRingtoneUri != null);
    }

    // On M devices the checked view's drawable state isn't updated properly when it is first
    // bound, so we must use a blunt approach to force it to refresh correctly.
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {
        listView.post(new Runnable() {
            @Override
            public void run() {
                for (int i = listView.getChildCount() - 1; i >= 0; --i) {
                    listView.getChildAt(i).refreshDrawableState();
                }
            }
        });
    }
}

From source file:Anim.ABaseTransformer.java

/**
 * Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)}.
 * <p>//from   w  w w. j  ava  2 s .  c om
 * The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
 * not modify the same page properties. For instance changing from a transformation that applies rotation to a
 * transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
 * alpha.
 *
 * @param page
 *            Apply the transformation to this page
 * @param position
 *            Position of page relative to the current front-and-center position of the pager. 0 is front and
 *            center. 1 is one full page position to the right, and -1 is one page position to the left.
 */
protected void onPreTransform(View page, float position) {
    final float width = page.getWidth();

    page.setRotationX(0);
    page.setRotationY(0);
    page.setRotation(0);
    page.setScaleX(1);
    page.setScaleY(1);
    page.setPivotX(0);
    page.setPivotY(0);
    page.setTranslationY(0);
    page.setTranslationX(isPagingEnabled() ? 0f : -width * position);

    if (hideOffscreenPages()) {
        page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
        page.setEnabled(false);
    } else {
        page.setEnabled(true);
        page.setAlpha(1f);
    }
}

From source file:com.howell.transformer.ABaseTransformer.java

/**
 * Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)}.
 * <p>/*w ww . java  2 s.  c om*/
 * The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
 * not modify the same page properties. For instance changing from a transformation that applies rotation to a
 * transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
 * alpha.
 * 
 * @param page
 *            Apply the transformation to this page
 * @param position
 *            Position of page relative to the current front-and-center position of the pager. 0 is front and
 *            center. 1 is one full page position to the right, and -1 is one page position to the left.
 */
@SuppressWarnings("ResourceType")
protected void onPreTransform(View page, float position) {
    final float width = page.getWidth();

    page.setRotationX(0);
    page.setRotationY(0);
    page.setRotation(0);
    page.setScaleX(1);
    page.setScaleY(1);
    page.setPivotX(0);
    page.setPivotY(0);
    page.setTranslationY(0);

    page.setTranslationX(isPagingEnabled() ? 0f : -width * position);

    if (hideOffscreenPages()) {
        page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
        page.setEnabled(false);
    } else {
        page.setEnabled(true);
        page.setAlpha(1f);
    }
}

From source file:com.dbeginc.dbweather.utils.animations.BasePageTransformer.java

/**
 * Called each {@link #transformPage(android.view.View, float)} before {{@link #onTransform(android.view.View, float)}.
 * <p>/*from   w  w  w  .  jav a 2  s.  com*/
 * The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
 * not modify the same page properties. For instance changing from a transformation that applies rotation to a
 * transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
 * alpha.
 *
 * @param page     Apply the transformation to this page
 * @param position Position of page relative to the current front-and-center position of the pager. 0 is front and
 *                 center. 1 is one full page position to the right, and -1 is one page position to the left.
 */
protected void onPreTransform(final View page, final float position) {
    final float width = page.getWidth();

    page.setRotationX(0);
    page.setRotationY(0);
    page.setRotation(0);
    page.setScaleX(1);
    page.setScaleY(1);
    page.setPivotX(0);
    page.setPivotY(0);
    page.setTranslationY(0);
    page.setTranslationX(isPagingEnabled() ? 0f : -width * position);

    if (hideOffscreenPages()) {
        page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
        page.setEnabled(false);
    } else {
        page.setEnabled(true);
        page.setAlpha(1f);
    }
}

From source file:com.shearosario.tothepathandback.DisplayDirectionsActivity.java

/**
 * If not at the first marker, moves to the previous step and shows the info window. If reaches the 
 * first marker, it disables itself. Also, if the next button is disabled and we're not at the last marker, it 
 * activates the next button. /*  www  . j  a  v  a 2  s  .  c  om*/
 * 
 * @param view button pressed
 */
public void previousStep(View view) {
    Button next = (Button) findViewById(R.id.button_nextStep);
    markersIndex--;

    if (!next.isEnabled() && markersIndex != (markers.size() - 1))
        next.setEnabled(true);

    gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(markers.get(markersIndex).getPosition(), 17));
    markers.get(markersIndex).showInfoWindow();

    if (markersIndex == 0)
        view.setEnabled(false);
}

From source file:android.widget.PinnedHeaderListAdapter.java

/**
 * The default implementation creates the same type of view as a normal
 * partition header.//from ww  w.  j a va 2 s .  c o  m
 */
@Override
public View getPinnedHeaderView(int partition, View convertView, ViewGroup parent) {
    if (hasHeader(partition)) {
        View view = null;
        if (convertView != null) {
            Integer headerType = (Integer) convertView.getTag();
            if (headerType != null && headerType == PARTITION_HEADER_TYPE) {
                view = convertView;
            }
        }
        if (view == null) {
            view = newHeaderView(getContext(), partition, null, parent);
            view.setTag(PARTITION_HEADER_TYPE);
            view.setFocusable(false);
            view.setEnabled(false);
        }
        bindHeaderView(view, partition, getCursor(partition));
        ViewCompat.setLayoutDirection(view, ViewCompat.getLayoutDirection(parent));
        return view;
    } else {
        return null;
    }
}

From source file:com.shearosario.tothepathandback.DisplayDirectionsActivity.java

/**
 * If not at the first marker, moves to the next step and shows the info window. If reaches the 
 * last marker, it disables itself. Also, if the previous button is disabled and we're not at the first marker, it 
 * activates the previous button. //www  .  j  av  a  2s  .com
 * 
 * @param view
 */
public void nextStep(View view) {
    Button previous = (Button) findViewById(R.id.button_previousStep);
    markersIndex++;

    if (!previous.isEnabled() && markersIndex != 0)
        previous.setEnabled(true);

    gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(markers.get(markersIndex).getPosition(), 17));
    markers.get(markersIndex).showInfoWindow();

    if (markersIndex == (markers.size() - 1))
        view.setEnabled(false);
}

From source file:edu.cens.loci.ui.widget.GenericEditorView.java

@Override
public void setEnabled(boolean enabled) {
    mLabel.setEnabled(enabled);/*from  ww  w  .  j  a va 2  s  .  c om*/
    final int count = mFields.getChildCount();
    for (int pos = 0; pos < count; pos++) {
        final View v = mFields.getChildAt(pos);
        v.setEnabled(enabled);
    }
    mMore.setEnabled(enabled);
    mLess.setEnabled(enabled);
}