android.widget.NumberPicker#setDescendantFocusability ( )源码实例Demo

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

源代码1 项目: arcusandroid   文件: NumericDayPopup.java
@Override
public void doContentSection() {
    int maxDaysToShow = 7;

    String[] days = new String[maxDaysToShow];

    //1-7 day(s) picker
    for (int dayNumber = 1; dayNumber < maxDaysToShow+1 ; dayNumber++) {
        int arrayNumber = dayNumber-1;
        if(dayNumber>1) days[arrayNumber] = (dayNumber)+" Days";
        else days[arrayNumber] = (dayNumber)+" Day";
    }
    picker = (NumberPicker) contentView.findViewById(R.id.floating_day_number_picker);
    picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    picker.setMinValue(0);
    picker.setMaxValue(maxDaysToShow - 1);
    picker.setDisplayedValues(days);
}
 
源代码2 项目: arcusandroid   文件: LocationPopup.java
@Override @SuppressWarnings({"unchecked"})
public void doContentSection() {
    if (getArguments() != null) {
        Serializable object = getArguments().getSerializable(LOCATIONS);
        if (object != null) {
            locations = (ArrayList<String>) object;
        }
    }

    picker = (NumberPicker) contentView.findViewById(R.id.floating_day_number_picker);
    picker.setVisibility(View.GONE);
    picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    picker.setMinValue(0);

    String[] displayedValues = new String[locations.size()];
    for (int i = 0; i < locations.size(); i++) {
        displayedValues[i] = locations.get(i);
    }

    picker.setMaxValue(displayedValues.length - 1);
    picker.setDisplayedValues(displayedValues);
    picker.setVisibility(View.VISIBLE);
}
 
源代码3 项目: arcusandroid   文件: TimezonePickerPopup.java
@Override public void doContentSection() {
    timezones = getTimezones();
    picker = (NumberPicker) contentView.findViewById(R.id.floating_day_number_picker);
    picker.setVisibility(View.GONE);
    picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    picker.setMinValue(0);

    String[] displayedValues = new String[timezones.size()];
    for (int i = 0; i < timezones.size(); i++) {
        displayedValues[i] = timezones.get(i).getName();
    }

    picker.setMaxValue(displayedValues.length - 1);
    picker.setDisplayedValues(displayedValues);
    picker.setValue(getIndexOfCurrentZoneOrDefault(0));
    picker.setVisibility(View.VISIBLE);

    Bundle args = getArguments();
    if (args == null) {
        forceNotification = false;
    } else {
        forceNotification = args.getBoolean(FORCE_NOTIFICATION, false);
    }
}
 
源代码4 项目: arcusandroid   文件: WeeklyIntervalPopup.java
@Override
public void doContentSection() {
    Calendar current = Calendar.getInstance();
    int maxDaysToShow = 7;

    String[] days = new String[maxDaysToShow];

    for (int i = 0; i < maxDaysToShow; i++) {
        if (i > 1) {
            days[i] = headerDateFormat.format(current.getTime());
        }
        else {
            days[i] = i == 0 ? getString(R.string.today) : getString(R.string.tomorrow);
        }
        current.add(Calendar.DAY_OF_MONTH, 1);
    }

    picker = (NumberPicker) contentView.findViewById(R.id.floating_day_number_picker);
    picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    picker.setMinValue(0);
    picker.setMaxValue(maxDaysToShow - 1);
    picker.setDisplayedValues(days);
}
 
源代码5 项目: Android-Webcam   文件: FormatPickerDialog.java
@Override
public void onStart() {
    super.onStart();
    setCancelable(false);

    numberPicker = (NumberPicker) getDialog().findViewById(R.id.number_picker);
    numberPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    numberPicker.setDisplayedValues(values);
    numberPicker.setMinValue(getMinimumValue());
    numberPicker.setMaxValue(getMaximumValue());
    numberPicker.setValue(getInitialValue());
    numberPicker.setWrapSelectorWheel(false);
    numberPicker.setOnValueChangedListener(new OnValueChangeListener() {
        @Override public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
            currentIndex = newVal;
        }
    });
}
 
源代码6 项目: arcusandroid   文件: OddDaysPopup.java
@Override
public void doContentSection() {
    Calendar current = Calendar.getInstance();
    String[] days = new String[7];
    int j=0;
    int i=0;
    do {
        if ( (current.get(Calendar.DAY_OF_MONTH) & 1) == 0 ) {
            i++;
        } else {
            if (i > 1) {
                days[j] = headerDateFormat.format(current.getTime());
            }
            else {
                days[j] = i == 0 ? getString(R.string.today) : getString(R.string.tomorrow);
            }
            j++;
            i++;
        }
        current.add(Calendar.DAY_OF_MONTH, 1);
    } while(i<14);

    picker = (NumberPicker) contentView.findViewById(R.id.floating_day_number_picker);
    picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    picker.setMinValue(0);
    picker.setMaxValue(6);
    picker.setDisplayedValues(days);
}
 
源代码7 项目: arcusandroid   文件: EvenDaysPopup.java
@Override
public void doContentSection() {
    Calendar current = Calendar.getInstance();
    String[] days = new String[7];
    int j=0;
    int i=0;
    do {
        if ( (current.get(Calendar.DAY_OF_MONTH) & 1) == 0 ) {
            if (i > 1) {
                days[j] = headerDateFormat.format(current.getTime());
            }
            else {
                days[j] = i == 0 ? getString(R.string.today) : getString(R.string.tomorrow);
            }
            j++;
            i++;
        } else {
            i++;
        }
        current.add(Calendar.DAY_OF_MONTH, 1);
    } while(i<14);

    picker = (NumberPicker) contentView.findViewById(R.id.floating_day_number_picker);
    picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    picker.setMinValue(0);
    picker.setMaxValue(6);
    picker.setDisplayedValues(days);
}
 
源代码8 项目: arcusandroid   文件: DayPickerPopup.java
@Override
public void doContentSection() {
    Calendar current = Calendar.getInstance();
    int DEFAULT_MAX_DAYS_TO_SHOW = 14;
    int maxDaysToShow = getNonNullArguments().getInt(MAX_DAYS, DEFAULT_MAX_DAYS_TO_SHOW);
    int dayAddOrSubtract = getNonNullArguments().getBoolean(DAYS_GOING_BACKWARDS, true) ? -1 : 1;
    String yesterdayTomorrowText = getString(getNonNullArguments().getBoolean(DAYS_GOING_BACKWARDS, true) ? R.string.yesterday : R.string.tomorrow);

    String[] days = new String[maxDaysToShow];

    for (int i = 0; i < maxDaysToShow; i++) {
        if (i > 1) {
            days[i] = headerDateFormat.format(current.getTime());
        }
        else {
            days[i] = i == 0 ? getString(R.string.today) : yesterdayTomorrowText;
        }
        current.add(Calendar.DAY_OF_MONTH, dayAddOrSubtract);
    }

    picker = (NumberPicker) contentView.findViewById(R.id.floating_day_number_picker);
    picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    picker.setMinValue(0);
    picker.setMaxValue(maxDaysToShow - 1);
    picker.setDisplayedValues(days);

    View divider = contentView.findViewById(R.id.picker_title_divider);
    if (divider != null) {
        divider.setVisibility(View.VISIBLE);
    }
}
 
源代码9 项目: Trebuchet   文件: DynamicGridSizeFragment.java
private void showNumberPicker() {
    mDialog = new Dialog(getActivity());
    mDialog.setTitle(getResources().getString(
            R.string.preferences_interface_homescreen_custom));
    mDialog.setContentView(R.layout.custom_grid_size_dialog);

    NumberPicker nPRows = (NumberPicker) mDialog.findViewById(R.id.custom_rows);
    NumberPicker nPColumns = (NumberPicker) mDialog.findViewById(R.id.custom_columns);

    InvariantDeviceProfile grid = getInvariantDeviceProfile();
    int rows = grid.numRowsBase;
    int columns = grid.numColumnsBase;

    nPRows.setMinValue(Math.max(MIN_DYNAMIC_GRID_ROWS, rows - InvariantDeviceProfile.GRID_SIZE_MIN));
    nPRows.setMaxValue(rows + InvariantDeviceProfile.GRID_SIZE_MAX);
    nPRows.setValue(mCustomGridRows);
    nPRows.setWrapSelectorWheel(false);
    nPRows.setOnValueChangedListener(this);
    nPRows.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);

    nPColumns.setMinValue(Math.max(MIN_DYNAMIC_GRID_COLUMNS,
            columns - InvariantDeviceProfile.GRID_SIZE_MIN));
    nPColumns.setMaxValue(columns + InvariantDeviceProfile.GRID_SIZE_MAX);
    nPColumns.setValue(mCustomGridColumns);
    nPColumns.setWrapSelectorWheel(false);
    nPColumns.setOnValueChangedListener(this);
    nPColumns.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);

    Button button = (Button) mDialog.findViewById(R.id.dialog_confirm_button);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mDialog != null) {
                mDialog.dismiss();
            }
        }
    });

    mDialog.setOnDismissListener(this);
    mDialog.show();
}
 
源代码10 项目: CrimeTalk-Reader   文件: NumberPickerPreference.java
@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;

}