Java Code Examples for android.widget.NumberPicker#getChildAt()

The following examples show how to use android.widget.NumberPicker#getChildAt() . 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: DayFragment.java    From SlideDayTimePicker with Apache License 2.0 6 votes vote down vote up
/**
 * Enable or disable NumberPicker editing. We use this to turn
 * off editing and this has the effect of removing the blinking
 * cursor that is shown by default.
 */
private void enableNumberPickerEditing(NumberPicker numberPicker, boolean enable)
{
    int childCount = numberPicker.getChildCount();

    for (int i = 0; i < childCount; i++)
    {
        View childView = numberPicker.getChildAt(i);

        if (childView instanceof EditText)
        {
            EditText editText = (EditText) childView;
            editText.setFocusable(enable);
            return;
        }
    }
}
 
Example 2
Source File: SDKUtils.java    From letv with Apache License 2.0 5 votes vote down vote up
public static View getChildAt(NumberPicker np, int index) {
    try {
        if (VERSION.SDK_INT >= 11) {
            return np.getChildAt(index);
        }
    } catch (Throwable e) {
        LOG.w(TAG, "get child failed(Throwable): " + e.getMessage());
    }
    return null;
}
 
Example 3
Source File: NumberPickerPreference.java    From CrimeTalk-Reader with Apache License 2.0 2 votes vote down vote up
@Override
@SuppressLint("InflateParams")
protected View onCreateDialogView() {

    final LayoutInflater layoutInflater = (LayoutInflater)
            getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final View view = layoutInflater.inflate(R.layout.preference_numberpicker, null);

    mNumberPicker = (NumberPicker) view.findViewById(R.id.number_picker);

    mNumberPicker.setMaxValue(25);
    mNumberPicker.setMinValue(5);
    mNumberPicker.setValue(getPersistedInt(10));
    mNumberPicker.setWrapSelectorWheel(false);
    mNumberPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);

    // There's a bug in the text color, correct it manually
    if (mNumberPicker.getChildCount() >= 1) {

        final View childView = mNumberPicker.getChildAt(1);

        if (childView != null && childView instanceof TextView) {

            if (PreferenceUtils.getDarkTheme(getContext())) {

                ((TextView) childView).setTextColor(getContext().getResources().getColor(R.color.white));

            } else {

                ((TextView) childView).setTextColor(getContext().getResources().getColor(R.color.black));

            }

        }

    }

    return view;

}