Example usage for android.widget ArrayAdapter setDropDownViewResource

List of usage examples for android.widget ArrayAdapter setDropDownViewResource

Introduction

In this page you can find the example usage for android.widget ArrayAdapter setDropDownViewResource.

Prototype

public void setDropDownViewResource(@LayoutRes int resource) 

Source Link

Document

Sets the layout resource to create the drop down views.

Usage

From source file:com.doomonafireball.betterpickers.recurrencepicker.RecurrencePickerDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRecurrence.wkst = EventRecurrence.timeDay2Day(Utils.getFirstDayOfWeek(getActivity()));

    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    boolean endCountHasFocus = false;
    if (savedInstanceState != null) {
        RecurrenceModel m = (RecurrenceModel) savedInstanceState.get(BUNDLE_MODEL);
        if (m != null) {
            mModel = m;/*from  w  w w. java  2s .  c o  m*/
        }
        endCountHasFocus = savedInstanceState.getBoolean(BUNDLE_END_COUNT_HAS_FOCUS);
    } else {
        Bundle b = getArguments();
        if (b != null) {
            mTime.set(b.getLong(BUNDLE_START_TIME_MILLIS));

            String tz = b.getString(BUNDLE_TIME_ZONE);
            if (!TextUtils.isEmpty(tz)) {
                mTime.timezone = tz;
            }
            mTime.normalize(false);

            // Time days of week: Sun=0, Mon=1, etc
            mModel.weeklyByDayOfWeek[mTime.weekDay] = true;
            String rrule = b.getString(BUNDLE_RRULE);
            if (!TextUtils.isEmpty(rrule)) {
                mModel.recurrenceState = RecurrenceModel.STATE_RECURRENCE;
                mRecurrence.parse(rrule);
                copyEventRecurrenceToModel(mRecurrence, mModel);
                // Leave today's day of week as checked by default in weekly view.
                if (mRecurrence.bydayCount == 0) {
                    mModel.weeklyByDayOfWeek[mTime.weekDay] = true;
                }
            }

        } else {
            mTime.setToNow();
        }
    }

    mResources = getResources();
    mView = inflater.inflate(R.layout.recurrencepicker, container, true);

    final Activity activity = getActivity();
    final Configuration config = activity.getResources().getConfiguration();

    mRepeatSwitch = (SwitchCompat) mView.findViewById(R.id.repeat_switch);
    mRepeatSwitch.setChecked(mModel.recurrenceState == RecurrenceModel.STATE_RECURRENCE);
    mRepeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mModel.recurrenceState = isChecked ? RecurrenceModel.STATE_RECURRENCE
                    : RecurrenceModel.STATE_NO_RECURRENCE;
            togglePickerOptions();
        }
    });

    mFreqSpinner = (Spinner) mView.findViewById(R.id.freqSpinner);
    mFreqSpinner.setOnItemSelectedListener(this);
    ArrayAdapter<CharSequence> freqAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.recurrence_freq, R.layout.recurrencepicker_freq_item);
    freqAdapter.setDropDownViewResource(R.layout.recurrencepicker_freq_item);
    mFreqSpinner.setAdapter(freqAdapter);

    mInterval = (EditText) mView.findViewById(R.id.interval);
    mInterval.addTextChangedListener(new minMaxTextWatcher(1, INTERVAL_DEFAULT, INTERVAL_MAX) {
        @Override
        void onChange(int v) {
            if (mIntervalResId != -1 && mInterval.getText().toString().length() > 0) {
                mModel.interval = v;
                updateIntervalText();
                mInterval.requestLayout();
            }
        }
    });
    mIntervalPreText = (TextView) mView.findViewById(R.id.intervalPreText);
    mIntervalPostText = (TextView) mView.findViewById(R.id.intervalPostText);

    mEndNeverStr = mResources.getString(R.string.recurrence_end_continously);
    mEndDateLabel = mResources.getString(R.string.recurrence_end_date_label);
    mEndCountLabel = mResources.getString(R.string.recurrence_end_count_label);

    mEndSpinnerArray.add(mEndNeverStr);
    mEndSpinnerArray.add(mEndDateLabel);
    mEndSpinnerArray.add(mEndCountLabel);
    mEndSpinner = (Spinner) mView.findViewById(R.id.endSpinner);
    mEndSpinner.setOnItemSelectedListener(this);
    mEndSpinnerAdapter = new EndSpinnerAdapter(getActivity(), mEndSpinnerArray,
            R.layout.recurrencepicker_freq_item, R.layout.recurrencepicker_end_text);
    mEndSpinnerAdapter.setDropDownViewResource(R.layout.recurrencepicker_freq_item);
    mEndSpinner.setAdapter(mEndSpinnerAdapter);

    mEndCount = (EditText) mView.findViewById(R.id.endCount);
    mEndCount.addTextChangedListener(new minMaxTextWatcher(1, COUNT_DEFAULT, COUNT_MAX) {
        @Override
        void onChange(int v) {
            if (mModel.endCount != v) {
                mModel.endCount = v;
                updateEndCountText();
                mEndCount.requestLayout();
            }
        }
    });
    mPostEndCount = (TextView) mView.findViewById(R.id.postEndCount);

    mEndDateTextView = (TextView) mView.findViewById(R.id.endDate);
    mEndDateTextView.setOnClickListener(this);
    if (mModel.endDate == null) {
        mModel.endDate = new Time(mTime);
        switch (mModel.freq) {
        case RecurrenceModel.FREQ_HOURLY:
        case RecurrenceModel.FREQ_DAILY:
        case RecurrenceModel.FREQ_WEEKLY:
            mModel.endDate.month += 1;
            break;
        case RecurrenceModel.FREQ_MONTHLY:
            mModel.endDate.month += 3;
            break;
        case RecurrenceModel.FREQ_YEARLY:
            mModel.endDate.year += 3;
            break;
        }
        mModel.endDate.normalize(false);
    }

    mWeekGroup = (LinearLayout) mView.findViewById(R.id.weekGroup);
    mWeekGroup2 = (LinearLayout) mView.findViewById(R.id.weekGroup2);

    // In Calendar.java day of week order e.g Sun = 1 ... Sat = 7
    String[] dayOfWeekString = new DateFormatSymbols().getWeekdays();

    mMonthRepeatByDayOfWeekStrs = new String[7][];
    // from Time.SUNDAY as 0 through Time.SATURDAY as 6
    mMonthRepeatByDayOfWeekStrs[0] = mResources.getStringArray(R.array.repeat_by_nth_sun);
    mMonthRepeatByDayOfWeekStrs[1] = mResources.getStringArray(R.array.repeat_by_nth_mon);
    mMonthRepeatByDayOfWeekStrs[2] = mResources.getStringArray(R.array.repeat_by_nth_tues);
    mMonthRepeatByDayOfWeekStrs[3] = mResources.getStringArray(R.array.repeat_by_nth_wed);
    mMonthRepeatByDayOfWeekStrs[4] = mResources.getStringArray(R.array.repeat_by_nth_thurs);
    mMonthRepeatByDayOfWeekStrs[5] = mResources.getStringArray(R.array.repeat_by_nth_fri);
    mMonthRepeatByDayOfWeekStrs[6] = mResources.getStringArray(R.array.repeat_by_nth_sat);

    // In Time.java day of week order e.g. Sun = 0
    int idx = Utils.getFirstDayOfWeek(getActivity());

    // In Calendar.java day of week order e.g Sun = 1 ... Sat = 7
    dayOfWeekString = new DateFormatSymbols().getShortWeekdays();

    int numOfButtonsInRow1;
    int numOfButtonsInRow2;

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) {
        // Get screen width in dp first
        Display display = getActivity().getWindowManager().getDefaultDisplay();
        DisplayMetrics outMetrics = new DisplayMetrics();
        display.getMetrics(outMetrics);

        float density = getResources().getDisplayMetrics().density;
        float dpWidth = outMetrics.widthPixels / density;
        if (dpWidth > MIN_SCREEN_WIDTH_FOR_SINGLE_ROW_WEEK) {
            numOfButtonsInRow1 = 7;
            numOfButtonsInRow2 = 0;
            mWeekGroup2.setVisibility(View.GONE);
            mWeekGroup2.getChildAt(3).setVisibility(View.GONE);
        } else {
            numOfButtonsInRow1 = 4;
            numOfButtonsInRow2 = 3;

            mWeekGroup2.setVisibility(View.VISIBLE);
            // Set rightmost button on the second row invisible so it takes up
            // space and everything centers properly
            mWeekGroup2.getChildAt(3).setVisibility(View.INVISIBLE);
        }
    } else if (mResources.getConfiguration().screenWidthDp > MIN_SCREEN_WIDTH_FOR_SINGLE_ROW_WEEK) {
        numOfButtonsInRow1 = 7;
        numOfButtonsInRow2 = 0;
        mWeekGroup2.setVisibility(View.GONE);
        mWeekGroup2.getChildAt(3).setVisibility(View.GONE);
    } else {
        numOfButtonsInRow1 = 4;
        numOfButtonsInRow2 = 3;

        mWeekGroup2.setVisibility(View.VISIBLE);
        // Set rightmost button on the second row invisible so it takes up
        // space and everything centers properly
        mWeekGroup2.getChildAt(3).setVisibility(View.INVISIBLE);
    }

    /* First row */
    for (int i = 0; i < 7; i++) {
        if (i >= numOfButtonsInRow1) {
            mWeekGroup.getChildAt(i).setVisibility(View.GONE);
            continue;
        }

        mWeekByDayButtons[idx] = (ToggleButton) mWeekGroup.getChildAt(i);
        mWeekByDayButtons[idx].setTextOff(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setTextOn(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setOnCheckedChangeListener(this);

        if (++idx >= 7) {
            idx = 0;
        }
    }

    /* 2nd Row */
    for (int i = 0; i < 3; i++) {
        if (i >= numOfButtonsInRow2) {
            mWeekGroup2.getChildAt(i).setVisibility(View.GONE);
            continue;
        }
        mWeekByDayButtons[idx] = (ToggleButton) mWeekGroup2.getChildAt(i);
        mWeekByDayButtons[idx].setTextOff(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setTextOn(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setOnCheckedChangeListener(this);

        if (++idx >= 7) {
            idx = 0;
        }
    }

    mMonthGroup = (LinearLayout) mView.findViewById(R.id.monthGroup);
    mMonthRepeatByRadioGroup = (RadioGroup) mView.findViewById(R.id.monthGroup);
    mMonthRepeatByRadioGroup.setOnCheckedChangeListener(this);
    mRepeatMonthlyByNthDayOfWeek = (RadioButton) mView.findViewById(R.id.repeatMonthlyByNthDayOfTheWeek);
    mRepeatMonthlyByNthDayOfMonth = (RadioButton) mView.findViewById(R.id.repeatMonthlyByNthDayOfMonth);

    mDoneButton = (Button) mView.findViewById(R.id.done_button);
    mDoneButton.setOnClickListener(this);

    Button cancelButton = (Button) mView.findViewById(R.id.cancel_button);
    //FIXME no text color for this one ?
    cancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });

    togglePickerOptions();
    updateDialog();
    if (endCountHasFocus) {
        mEndCount.requestFocus();
    }
    return mView;
}

From source file:com.example.android.contactslist.ui.eventEntry.EventEntryFragment.java

private void addItemsToClassSpinner() {

    //set the adapter to the string-array in the strings resource
    ArrayAdapter<String> feedSelectionAdapter = new ArrayAdapter<String>(getActivity(),
            android.R.layout.simple_spinner_item,
            getResources().getStringArray(R.array.array_of_event_classes));

    //choose the style of the list.
    feedSelectionAdapter.setDropDownViewResource(android.R.layout.simple_list_item_activated_1);

    mClassSelectionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override//from  w w w . ja  va2s.  c o  m
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {

            mEventClass = pos + 1; // set the event class for this java class

            switch (mEventClass) {
            case EventInfo.PHONE_CLASS:
                mAddressViewButton.setText(mVoiceNumber);
                mAddressViewButton.setInputType(InputType.TYPE_CLASS_PHONE);
                mEventDurationLayout.setVisibility(View.VISIBLE);
                mEventWordCountLayout.setVisibility(View.GONE);
                mIncomingButton.setText(R.string.incoming_title);
                mOutgoingButton.setText(R.string.outgoing_title);
                mAddressTitle.setText(R.string.event_address_title_alt_phone);

                break;
            case EventInfo.EMAIL_CLASS:
                mAddressViewButton.setText(mEmailAddress);
                mAddressViewButton.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
                mEventDurationLayout.setVisibility(View.GONE);
                mEventWordCountLayout.setVisibility(View.VISIBLE);
                mIncomingButton.setText(R.string.incoming_title);
                mOutgoingButton.setText(R.string.outgoing_title);
                mAddressTitle.setText(R.string.event_address_title);

                break;
            case EventInfo.SMS_CLASS:
                mAddressViewButton.setText(mVoiceNumber);
                mAddressViewButton.setInputType(InputType.TYPE_CLASS_PHONE);
                mEventDurationLayout.setVisibility(View.GONE);
                mEventWordCountLayout.setVisibility(View.VISIBLE);
                mIncomingButton.setText(R.string.incoming_title);
                mOutgoingButton.setText(R.string.outgoing_title);
                mAddressTitle.setText(R.string.event_address_title_alt_phone);

                break;
            case EventInfo.MEETING_CLASS:
                mAddressViewButton.setText(mStreetAddress);
                mAddressViewButton.setInputType(InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS);
                mEventDurationLayout.setVisibility(View.VISIBLE);
                mEventWordCountLayout.setVisibility(View.GONE);
                mIncomingButton.setText(R.string.incoming_title_alt);
                mOutgoingButton.setText(R.string.outgoing_title_alt);
                mAddressTitle.setText(R.string.event_address_title);

                break;
            case EventInfo.SKYPE:
                mEventDurationLayout.setVisibility(View.VISIBLE);
                mEventWordCountLayout.setVisibility(View.GONE);
                mIncomingButton.setText(R.string.incoming_title);
                mOutgoingButton.setText(R.string.outgoing_title);
                mAddressTitle.setText(R.string.event_address_title_alt_handle);

                break;
            case EventInfo.GOOGLE_HANGOUTS:
                mAddressViewButton.setText(mEmailAddress);
                mAddressViewButton.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
                mEventDurationLayout.setVisibility(View.VISIBLE);
                mEventWordCountLayout.setVisibility(View.GONE);
                mIncomingButton.setText(R.string.incoming_title);
                mOutgoingButton.setText(R.string.outgoing_title);
                mAddressTitle.setText(R.string.event_address_title_alt_handle);

                break;
            case EventInfo.FACEBOOK:
                mAddressViewButton.setText(mEmailAddress);
                mAddressViewButton.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
                mEventDurationLayout.setVisibility(View.GONE);
                mEventWordCountLayout.setVisibility(View.VISIBLE);
                mIncomingButton.setText(R.string.incoming_title);
                mOutgoingButton.setText(R.string.outgoing_title);
                mAddressTitle.setText(R.string.event_address_title_alt_handle);

                break;

            default:
            }

        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub
        }
    });

    mClassSelectionSpinner.setAdapter(feedSelectionAdapter);
}

From source file:com.elpstudio.player.EqualizerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    //Context./*from   ww w .jav  a  2  s.  com*/
    mContext = getApplicationContext();
    mApp = (Common) mContext.getApplicationContext();
    mFragment = this;

    //setTheme();
    super.onCreate(savedInstanceState);

    //Equalizer container elements.
    mScrollView = (ScrollView) findViewById(R.id.equalizerScrollView);

    //50Hz equalizer controls.
    equalizer50HzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer50Hz);
    text50HzGainTextView = (TextView) findViewById(R.id.text50HzGain);
    text50Hz = (TextView) findViewById(R.id.text50Hz);

    //130Hz equalizer controls.
    equalizer130HzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer130Hz);
    text130HzGainTextView = (TextView) findViewById(R.id.text130HzGain);
    text130Hz = (TextView) findViewById(R.id.text130Hz);

    //320Hz equalizer controls.
    equalizer320HzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer320Hz);
    text320HzGainTextView = (TextView) findViewById(R.id.text320HzGain);
    text320Hz = (TextView) findViewById(R.id.text320Hz);

    //800Hz equalizer controls.
    equalizer800HzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer800Hz);
    text800HzGainTextView = (TextView) findViewById(R.id.text800HzGain);
    text800Hz = (TextView) findViewById(R.id.text800Hz);

    //2kHz equalizer controls.
    equalizer2kHzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer2kHz);
    text2kHzGainTextView = (TextView) findViewById(R.id.text2kHzGain);
    text2kHz = (TextView) findViewById(R.id.text2kHz);

    //5kHz equalizer controls.
    equalizer5kHzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer5kHz);
    text5kHzGainTextView = (TextView) findViewById(R.id.text5kHzGain);
    text5kHz = (TextView) findViewById(R.id.text5kHz);

    //12.5kHz equalizer controls.
    equalizer12_5kHzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer12_5kHz);
    text12_5kHzGainTextView = (TextView) findViewById(R.id.text12_5kHzGain);
    text12_5kHz = (TextView) findViewById(R.id.text12_5kHz);

    //Audio FX elements.
    virtualizerSeekBar = (SeekBar) findViewById(R.id.virtualizer_seekbar);
    bassBoostSeekBar = (SeekBar) findViewById(R.id.bass_boost_seekbar);
    reverbSpinner = (Spinner) findViewById(R.id.reverb_spinner);
    virtualizerTitle = (TextView) findViewById(R.id.virtualizer_title_text);
    bassBoostTitle = (TextView) findViewById(R.id.bass_boost_title_text);
    reverbTitle = (TextView) findViewById(R.id.reverb_title_text);

    /*text50HzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text130HzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text320HzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text800HzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text2kHzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text5kHzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text12_5kHzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text50Hz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text130Hz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text320Hz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text800Hz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text2kHz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text5kHz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text12_5kHz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
            
    loadPresetText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Bold"));
    savePresetText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Bold"));
    resetAllText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Bold"));*/

    text50HzGainTextView.setPaintFlags(
            text50HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text130HzGainTextView.setPaintFlags(
            text130HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text320HzGainTextView.setPaintFlags(
            text320HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text800HzGainTextView.setPaintFlags(
            text130HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text2kHzGainTextView.setPaintFlags(
            text320HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text5kHzGainTextView.setPaintFlags(
            text130HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text12_5kHzGainTextView.setPaintFlags(
            text320HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text50Hz.setPaintFlags(text50Hz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text130Hz.setPaintFlags(text130Hz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text320Hz.setPaintFlags(text320Hz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text800Hz.setPaintFlags(text800Hz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text2kHz.setPaintFlags(text2kHz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text5kHz.setPaintFlags(text5kHz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text12_5kHz.setPaintFlags(text12_5kHz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);

    text50HzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text130HzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text320HzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text800HzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text2kHzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text5kHzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text12_5kHzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text50Hz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text130Hz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text320Hz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text800Hz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text2kHz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text5kHz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text12_5kHz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));

    //Init reverb presets.
    ArrayList<String> reverbPresets = new ArrayList<String>();
    reverbPresets.add("None");
    reverbPresets.add("Large Hall");
    reverbPresets.add("Large Room");
    reverbPresets.add("Medium Hall");
    reverbPresets.add("Medium Room");
    reverbPresets.add("Small Room");
    reverbPresets.add("Plate");

    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            reverbPresets);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    reverbSpinner.setAdapter(dataAdapter);

    //Set the max values for the seekbars.
    virtualizerSeekBar.setMax(1000);
    bassBoostSeekBar.setMax(1000);

    //virtualizerTitle.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    virtualizerTitle.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    virtualizerTitle
            .setPaintFlags(virtualizerTitle.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    // bassBoostTitle.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    bassBoostTitle.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    bassBoostTitle
            .setPaintFlags(bassBoostTitle.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    //reverbTitle.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    reverbTitle.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    reverbTitle.setPaintFlags(reverbTitle.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    equalizer50HzSeekBar.setOnSeekBarChangeListener(equalizer50HzListener);
    equalizer130HzSeekBar.setOnSeekBarChangeListener(equalizer130HzListener);
    equalizer320HzSeekBar.setOnSeekBarChangeListener(equalizer320HzListener);
    equalizer800HzSeekBar.setOnSeekBarChangeListener(equalizer800HzListener);
    equalizer2kHzSeekBar.setOnSeekBarChangeListener(equalizer2kHzListener);
    equalizer5kHzSeekBar.setOnSeekBarChangeListener(equalizer5kHzListener);
    equalizer12_5kHzSeekBar.setOnSeekBarChangeListener(equalizer12_5kHzListener);

    virtualizerSeekBar.setOnSeekBarChangeListener(virtualizerListener);
    bassBoostSeekBar.setOnSeekBarChangeListener(bassBoostListener);
    reverbSpinner.setOnItemSelectedListener(reverbListener);

    //Get the saved equalizer settings and apply them to the UI elements.
    new AsyncInitSlidersTask().execute();
    /*
            getSupportActionBar().setHomeButtonEnabled(false);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);*/
}

From source file:com.mattfred.betterpickers.recurrencepicker.RecurrencePickerDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRecurrence.wkst = EventRecurrence.timeDay2Day(Utils.getFirstDayOfWeek(getActivity()));

    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    boolean endCountHasFocus = false;
    if (savedInstanceState != null) {
        RecurrenceModel m = (RecurrenceModel) savedInstanceState.get(BUNDLE_MODEL);
        if (m != null) {
            mModel = m;/*from w  w w .  j  a  v  a 2  s  . c  om*/
        }
        endCountHasFocus = savedInstanceState.getBoolean(BUNDLE_END_COUNT_HAS_FOCUS);
    } else {
        Bundle bundle = getArguments();
        if (bundle != null) {
            mTime.set(bundle.getLong(BUNDLE_START_TIME_MILLIS));

            String tz = bundle.getString(BUNDLE_TIME_ZONE);
            if (!TextUtils.isEmpty(tz)) {
                mTime.timezone = tz;
            }
            mTime.normalize(false);

            // Time days of week: Sun=0, Mon=1, etc
            mModel.weeklyByDayOfWeek[mTime.weekDay] = true;
            String rrule = bundle.getString(BUNDLE_RRULE);
            if (!TextUtils.isEmpty(rrule)) {
                mModel.recurrenceState = RecurrenceModel.STATE_RECURRENCE;
                mRecurrence.parse(rrule);
                copyEventRecurrenceToModel(mRecurrence, mModel);
                // Leave today's day of week as checked by default in weekly view.
                if (mRecurrence.bydayCount == 0) {
                    mModel.weeklyByDayOfWeek[mTime.weekDay] = true;
                }
            }

            mModel.forceHideSwitchButton = bundle.getBoolean(BUNDLE_HIDE_SWITCH_BUTTON, false);
        } else {
            mTime.setToNow();
        }
    }

    mResources = getResources();
    mView = inflater.inflate(R.layout.recurrencepicker, container, true);

    final Activity activity = getActivity();
    final Configuration config = activity.getResources().getConfiguration();

    mRepeatSwitch = (SwitchCompat) mView.findViewById(R.id.repeat_switch);
    if (mModel.forceHideSwitchButton) {
        mRepeatSwitch.setChecked(true);
        mRepeatSwitch.setVisibility(View.GONE);
        mModel.recurrenceState = RecurrenceModel.STATE_RECURRENCE;
    } else {
        mRepeatSwitch.setChecked(mModel.recurrenceState == RecurrenceModel.STATE_RECURRENCE);
        mRepeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mModel.recurrenceState = isChecked ? RecurrenceModel.STATE_RECURRENCE
                        : RecurrenceModel.STATE_NO_RECURRENCE;
                togglePickerOptions();
            }
        });
    }
    mFreqSpinner = (Spinner) mView.findViewById(R.id.freqSpinner);
    mFreqSpinner.setOnItemSelectedListener(this);
    ArrayAdapter<CharSequence> freqAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.recurrence_freq, R.layout.recurrencepicker_freq_item);
    freqAdapter.setDropDownViewResource(R.layout.recurrencepicker_freq_item);
    mFreqSpinner.setAdapter(freqAdapter);

    mInterval = (EditText) mView.findViewById(R.id.interval);
    mInterval.addTextChangedListener(new minMaxTextWatcher(1, INTERVAL_DEFAULT, INTERVAL_MAX) {
        @Override
        void onChange(int v) {
            if (mIntervalResId != -1 && mInterval.getText().toString().length() > 0) {
                mModel.interval = v;
                updateIntervalText();
                mInterval.requestLayout();
            }
        }
    });
    mIntervalPreText = (TextView) mView.findViewById(R.id.intervalPreText);
    mIntervalPostText = (TextView) mView.findViewById(R.id.intervalPostText);

    mEndNeverStr = mResources.getString(R.string.recurrence_end_continously);
    mEndDateLabel = mResources.getString(R.string.recurrence_end_date_label);
    mEndCountLabel = mResources.getString(R.string.recurrence_end_count_label);

    mEndSpinnerArray.add(mEndNeverStr);
    mEndSpinnerArray.add(mEndDateLabel);
    mEndSpinnerArray.add(mEndCountLabel);
    mEndSpinner = (Spinner) mView.findViewById(R.id.endSpinner);
    mEndSpinner.setOnItemSelectedListener(this);
    mEndSpinnerAdapter = new EndSpinnerAdapter(getActivity(), mEndSpinnerArray,
            R.layout.recurrencepicker_freq_item, R.layout.recurrencepicker_end_text);
    mEndSpinnerAdapter.setDropDownViewResource(R.layout.recurrencepicker_freq_item);
    mEndSpinner.setAdapter(mEndSpinnerAdapter);

    mEndCount = (EditText) mView.findViewById(R.id.endCount);
    mEndCount.addTextChangedListener(new minMaxTextWatcher(1, COUNT_DEFAULT, COUNT_MAX) {
        @Override
        void onChange(int v) {
            if (mModel.endCount != v) {
                mModel.endCount = v;
                updateEndCountText();
                mEndCount.requestLayout();
            }
        }
    });
    mPostEndCount = (TextView) mView.findViewById(R.id.postEndCount);

    mEndDateTextView = (TextView) mView.findViewById(R.id.endDate);
    mEndDateTextView.setOnClickListener(this);
    if (mModel.endDate == null) {
        mModel.endDate = new Time(mTime);
        switch (mModel.freq) {
        case RecurrenceModel.FREQ_HOURLY:
        case RecurrenceModel.FREQ_DAILY:
        case RecurrenceModel.FREQ_WEEKLY:
            mModel.endDate.month += 1;
            break;
        case RecurrenceModel.FREQ_MONTHLY:
            mModel.endDate.month += 3;
            break;
        case RecurrenceModel.FREQ_YEARLY:
            mModel.endDate.year += 3;
            break;
        }
        mModel.endDate.normalize(false);
    }

    mWeekGroup = (LinearLayout) mView.findViewById(R.id.weekGroup);
    mWeekGroup2 = (LinearLayout) mView.findViewById(R.id.weekGroup2);

    // In Calendar.java day of week order e.g Sun = 1 ... Sat = 7
    String[] dayOfWeekString = new DateFormatSymbols().getWeekdays();

    mMonthRepeatByDayOfWeekStrs = new String[7][];
    // from Time.SUNDAY as 0 through Time.SATURDAY as 6
    mMonthRepeatByDayOfWeekStrs[0] = mResources.getStringArray(R.array.repeat_by_nth_sun);
    mMonthRepeatByDayOfWeekStrs[1] = mResources.getStringArray(R.array.repeat_by_nth_mon);
    mMonthRepeatByDayOfWeekStrs[2] = mResources.getStringArray(R.array.repeat_by_nth_tues);
    mMonthRepeatByDayOfWeekStrs[3] = mResources.getStringArray(R.array.repeat_by_nth_wed);
    mMonthRepeatByDayOfWeekStrs[4] = mResources.getStringArray(R.array.repeat_by_nth_thurs);
    mMonthRepeatByDayOfWeekStrs[5] = mResources.getStringArray(R.array.repeat_by_nth_fri);
    mMonthRepeatByDayOfWeekStrs[6] = mResources.getStringArray(R.array.repeat_by_nth_sat);

    // In Time.java day of week order e.g. Sun = 0
    int idx = Utils.getFirstDayOfWeek(getActivity());

    // In Calendar.java day of week order e.g Sun = 1 ... Sat = 7
    dayOfWeekString = new DateFormatSymbols().getShortWeekdays();

    int numOfButtonsInRow1;
    int numOfButtonsInRow2;

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) {
        // Get screen width in dp first
        Display display = getActivity().getWindowManager().getDefaultDisplay();
        DisplayMetrics outMetrics = new DisplayMetrics();
        display.getMetrics(outMetrics);

        float density = getResources().getDisplayMetrics().density;
        float dpWidth = outMetrics.widthPixels / density;
        if (dpWidth > MIN_SCREEN_WIDTH_FOR_SINGLE_ROW_WEEK) {
            numOfButtonsInRow1 = 7;
            numOfButtonsInRow2 = 0;
            mWeekGroup2.setVisibility(View.GONE);
            mWeekGroup2.getChildAt(3).setVisibility(View.GONE);
        } else {
            numOfButtonsInRow1 = 4;
            numOfButtonsInRow2 = 3;

            mWeekGroup2.setVisibility(View.VISIBLE);
            // Set rightmost button on the second row invisible so it takes up
            // space and everything centers properly
            mWeekGroup2.getChildAt(3).setVisibility(View.INVISIBLE);
        }
    } else if (mResources.getConfiguration().screenWidthDp > MIN_SCREEN_WIDTH_FOR_SINGLE_ROW_WEEK) {
        numOfButtonsInRow1 = 7;
        numOfButtonsInRow2 = 0;
        mWeekGroup2.setVisibility(View.GONE);
        mWeekGroup2.getChildAt(3).setVisibility(View.GONE);
    } else {
        numOfButtonsInRow1 = 4;
        numOfButtonsInRow2 = 3;

        mWeekGroup2.setVisibility(View.VISIBLE);
        // Set rightmost button on the second row invisible so it takes up
        // space and everything centers properly
        mWeekGroup2.getChildAt(3).setVisibility(View.INVISIBLE);
    }

    /* First row */
    for (int i = 0; i < 7; i++) {
        if (i >= numOfButtonsInRow1) {
            mWeekGroup.getChildAt(i).setVisibility(View.GONE);
            continue;
        }

        mWeekByDayButtons[idx] = (ToggleButton) mWeekGroup.getChildAt(i);
        mWeekByDayButtons[idx].setTextOff(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setTextOn(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setOnCheckedChangeListener(this);

        if (++idx >= 7) {
            idx = 0;
        }
    }

    /* 2nd Row */
    for (int i = 0; i < 3; i++) {
        if (i >= numOfButtonsInRow2) {
            mWeekGroup2.getChildAt(i).setVisibility(View.GONE);
            continue;
        }
        mWeekByDayButtons[idx] = (ToggleButton) mWeekGroup2.getChildAt(i);
        mWeekByDayButtons[idx].setTextOff(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setTextOn(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setOnCheckedChangeListener(this);

        if (++idx >= 7) {
            idx = 0;
        }
    }

    mMonthGroup = (LinearLayout) mView.findViewById(R.id.monthGroup);
    mMonthRepeatByRadioGroup = (RadioGroup) mView.findViewById(R.id.monthGroup);
    mMonthRepeatByRadioGroup.setOnCheckedChangeListener(this);
    mRepeatMonthlyByNthDayOfWeek = (RadioButton) mView.findViewById(R.id.repeatMonthlyByNthDayOfTheWeek);
    mRepeatMonthlyByNthDayOfMonth = (RadioButton) mView.findViewById(R.id.repeatMonthlyByNthDayOfMonth);

    mDoneButton = (Button) mView.findViewById(R.id.done_button);
    mDoneButton.setOnClickListener(this);

    Button cancelButton = (Button) mView.findViewById(R.id.cancel_button);
    //FIXME no text color for this one ?
    cancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });

    togglePickerOptions();
    updateDialog();
    if (endCountHasFocus) {
        mEndCount.requestFocus();
    }
    return mView;
}

From source file:com.money.manager.ex.transactions.EditTransactionCommonFunctions.java

/**
 * Initialize account selectors./*from ww w. j  a v  a 2s.  c  om*/
 */
public void initAccountSelectors() {
    AppSettings settings = new AppSettings(getContext());

    // Account list as the data source to populate the drop-downs.

    AccountService accountService = new AccountService(getContext());
    this.AccountList = accountService.getTransactionAccounts(
            settings.getLookAndFeelSettings().getViewOpenAccounts(),
            settings.getLookAndFeelSettings().getViewFavouriteAccounts());
    if (this.AccountList == null)
        return;

    for (Account account : this.AccountList) {
        mAccountNameList.add(account.getName());
        mAccountIdList.add(account.getId());
    }

    AccountRepository accountRepository = new AccountRepository(getContext());
    Integer accountId = transactionEntity.getAccountId();
    if (accountId != null) {
        addMissingAccountToSelectors(accountRepository, accountId);
    }
    addMissingAccountToSelectors(accountRepository, transactionEntity.getAccountToId());
    // add the default account, if any.
    Integer defaultAccount = settings.getGeneralSettings().getDefaultAccountId();
    // Set the current account, if not set already.
    if ((accountId != null && accountId == Constants.NOT_SET)
            && (defaultAccount != null && defaultAccount != Constants.NOT_SET)) {
        accountId = defaultAccount;
        addMissingAccountToSelectors(accountRepository, accountId);
        // Set the default account as the active account.
        transactionEntity.setAccountId(accountId);
    }

    // Adapter for account selectors.

    ArrayAdapter<String> accountAdapter = new ArrayAdapter<>(getActivity(),
            android.R.layout.simple_spinner_item, mAccountNameList);

    accountAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    viewHolder.spinAccount.setAdapter(accountAdapter);
    viewHolder.spinAccountTo.setAdapter(accountAdapter);

    // Selection handler.

    AdapterView.OnItemSelectedListener listener = new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if ((position < 0) || (position > mAccountIdList.size())) {
                return;
            }

            setDirty(true);

            boolean isSource = parent == viewHolder.spinAccount;
            boolean isTransfer = transactionEntity.getTransactionType() == TransactionTypes.Transfer;
            Integer accountId = mAccountIdList.get(position);

            if (isSource) {
                int originalCurrencyId = getSourceCurrencyId();

                transactionEntity.setAccountId(accountId);

                if (isTransfer) {
                    // calculate the exchange amount if it is 0.
                    if (transactionEntity.getAmountTo().isZero()) {
                        Money convertedAmount = calculateAmountTo();
                        transactionEntity.setAmountTo(convertedAmount);
                        displayAmountTo();
                    }
                    // Recalculate the original amount when the currency changes.
                    if (originalCurrencyId != getSourceCurrencyId()) {
                        Money exchangeAmount = calculateAmountFrom();
                        transactionEntity.setAmount(exchangeAmount);
                        displayAmountFrom();
                    }
                } else {
                    displayAmountFrom();
                }
            } else {
                int originalCurrencyId = getDestinationCurrencyId();

                transactionEntity.setAccountToId(accountId);

                if (isTransfer) {
                    // calculate the exchange amount if it is 0.
                    if (transactionEntity.getAmount().isZero()) {
                        Money convertedAmount = calculateAmountFrom();
                        transactionEntity.setAmount(convertedAmount);
                        displayAmountFrom();
                    }
                    // Recalculate the original amount when the currency changes.
                    if (originalCurrencyId != getDestinationCurrencyId()) {
                        Money exchangeAmount = calculateAmountTo();
                        transactionEntity.setAmountTo(exchangeAmount);
                        displayAmountTo();
                    }
                } else {
                    displayAmountTo();
                }
            }

            refreshControlTitles();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    };

    // Account

    int accountIndex = mAccountIdList.indexOf(accountId);
    if (accountIndex >= 0) {
        viewHolder.spinAccount.setSelection(accountIndex, true);
    }
    viewHolder.spinAccount.setOnItemSelectedListener(listener);

    // To Account

    if (transactionEntity.hasAccountTo() && mAccountIdList.indexOf(transactionEntity.getAccountToId()) >= 0) {
        viewHolder.spinAccountTo.setSelection(mAccountIdList.indexOf(transactionEntity.getAccountToId()), true);
    }
    viewHolder.spinAccountTo.setOnItemSelectedListener(listener);
}

From source file:com.codetroopers.betterpickers.recurrencepicker.RecurrencePickerDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRecurrence.wkst = EventRecurrence.timeDay2Day(Utils.getFirstDayOfWeek(getActivity()));

    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    boolean endCountHasFocus = false;
    if (savedInstanceState != null) {
        RecurrenceModel m = (RecurrenceModel) savedInstanceState.get(BUNDLE_MODEL);
        if (m != null) {
            mModel = m;//from   w  w w .j  a  v a2  s . com
        }
        endCountHasFocus = savedInstanceState.getBoolean(BUNDLE_END_COUNT_HAS_FOCUS);
    } else {
        Bundle bundle = getArguments();
        if (bundle != null) {
            mTime.set(bundle.getLong(BUNDLE_START_TIME_MILLIS));

            String tz = bundle.getString(BUNDLE_TIME_ZONE);
            if (!TextUtils.isEmpty(tz)) {
                mTime.timezone = tz;
            }
            mTime.normalize(false);

            // Time days of week: Sun=0, Mon=1, etc
            mModel.weeklyByDayOfWeek[mTime.weekDay] = true;
            String rrule = bundle.getString(BUNDLE_RRULE);
            if (!TextUtils.isEmpty(rrule)) {
                mModel.recurrenceState = RecurrenceModel.STATE_RECURRENCE;
                mRecurrence.parse(rrule);
                copyEventRecurrenceToModel(mRecurrence, mModel);
                // Leave today's day of week as checked by default in weekly view.
                if (mRecurrence.bydayCount == 0) {
                    mModel.weeklyByDayOfWeek[mTime.weekDay] = true;
                }
            }

            mModel.forceHideSwitchButton = bundle.getBoolean(BUNDLE_HIDE_SWITCH_BUTTON, false);
        } else {
            mTime.setToNow();
        }
    }

    mResources = getResources();
    mView = inflater.inflate(R.layout.recurrencepicker, container, true);

    final Activity activity = getActivity();
    final Configuration config = activity.getResources().getConfiguration();

    mRepeatSwitch = (SwitchCompat) mView.findViewById(R.id.repeat_switch);
    if (mModel.forceHideSwitchButton) {
        mRepeatSwitch.setChecked(true);
        mRepeatSwitch.setVisibility(View.GONE);
        mModel.recurrenceState = RecurrenceModel.STATE_RECURRENCE;
    } else {
        mRepeatSwitch.setChecked(mModel.recurrenceState == RecurrenceModel.STATE_RECURRENCE);
        mRepeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mModel.recurrenceState = isChecked ? RecurrenceModel.STATE_RECURRENCE
                        : RecurrenceModel.STATE_NO_RECURRENCE;
                togglePickerOptions();
            }
        });
    }
    mFreqSpinner = (Spinner) mView.findViewById(R.id.freqSpinner);
    mFreqSpinner.setOnItemSelectedListener(this);
    ArrayAdapter<CharSequence> freqAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.recurrence_freq, R.layout.recurrencepicker_freq_item);
    freqAdapter.setDropDownViewResource(R.layout.recurrencepicker_freq_item);
    mFreqSpinner.setAdapter(freqAdapter);

    mInterval = (EditText) mView.findViewById(R.id.interval);
    mInterval.addTextChangedListener(new minMaxTextWatcher(1, INTERVAL_DEFAULT, INTERVAL_MAX) {
        @Override
        void onChange(int v) {
            if (mIntervalResId != -1 && mInterval.getText().toString().length() > 0) {
                mModel.interval = v;
                updateIntervalText();
                mInterval.requestLayout();
            }
        }
    });
    mIntervalPreText = (TextView) mView.findViewById(R.id.intervalPreText);
    mIntervalPostText = (TextView) mView.findViewById(R.id.intervalPostText);

    mEndNeverStr = mResources.getString(R.string.recurrence_end_continously);
    mEndDateLabel = mResources.getString(R.string.recurrence_end_date_label);
    mEndCountLabel = mResources.getString(R.string.recurrence_end_count_label);

    mEndSpinnerArray.add(mEndNeverStr);
    mEndSpinnerArray.add(mEndDateLabel);
    mEndSpinnerArray.add(mEndCountLabel);
    mEndSpinner = (Spinner) mView.findViewById(R.id.endSpinner);
    mEndSpinner.setOnItemSelectedListener(this);
    mEndSpinnerAdapter = new EndSpinnerAdapter(getActivity(), mEndSpinnerArray,
            R.layout.recurrencepicker_freq_item, R.layout.recurrencepicker_end_text);
    mEndSpinnerAdapter.setDropDownViewResource(R.layout.recurrencepicker_freq_item);
    mEndSpinner.setAdapter(mEndSpinnerAdapter);

    mEndCount = (EditText) mView.findViewById(R.id.endCount);
    mEndCount.addTextChangedListener(new minMaxTextWatcher(1, COUNT_DEFAULT, COUNT_MAX) {
        @Override
        void onChange(int v) {
            if (mModel.endCount != v) {
                mModel.endCount = v;
                updateEndCountText();
                mEndCount.requestLayout();
            }
        }
    });
    mPostEndCount = (TextView) mView.findViewById(R.id.postEndCount);

    mEndDateTextView = (TextView) mView.findViewById(R.id.endDate);
    mEndDateTextView.setOnClickListener(this);
    if (mModel.endDate == null) {
        mModel.endDate = new Time(mTime);
        switch (mModel.freq) {
        case RecurrenceModel.FREQ_HOURLY:
        case RecurrenceModel.FREQ_DAILY:
        case RecurrenceModel.FREQ_WEEKLY:
            mModel.endDate.month += 1;
            break;
        case RecurrenceModel.FREQ_MONTHLY:
            mModel.endDate.month += 3;
            break;
        case RecurrenceModel.FREQ_YEARLY:
            mModel.endDate.year += 3;
            break;
        }
        mModel.endDate.normalize(false);
    }

    mWeekGroup = (LinearLayout) mView.findViewById(R.id.weekGroup);
    mWeekGroup2 = (LinearLayout) mView.findViewById(R.id.weekGroup2);

    // In Calendar.java day of week order e.g Sun = 1 ... Sat = 7
    String[] dayOfWeekString = new DateFormatSymbols().getWeekdays();

    mMonthRepeatByDayOfWeekStrs = new String[7][];
    // from Time.SUNDAY as 0 through Time.SATURDAY as 6
    mMonthRepeatByDayOfWeekStrs[0] = mResources.getStringArray(R.array.repeat_by_nth_sun);
    mMonthRepeatByDayOfWeekStrs[1] = mResources.getStringArray(R.array.repeat_by_nth_mon);
    mMonthRepeatByDayOfWeekStrs[2] = mResources.getStringArray(R.array.repeat_by_nth_tues);
    mMonthRepeatByDayOfWeekStrs[3] = mResources.getStringArray(R.array.repeat_by_nth_wed);
    mMonthRepeatByDayOfWeekStrs[4] = mResources.getStringArray(R.array.repeat_by_nth_thurs);
    mMonthRepeatByDayOfWeekStrs[5] = mResources.getStringArray(R.array.repeat_by_nth_fri);
    mMonthRepeatByDayOfWeekStrs[6] = mResources.getStringArray(R.array.repeat_by_nth_sat);

    // In Time.java day of week order e.g. Sun = 0
    int idx = Utils.getFirstDayOfWeek(getActivity());

    // In Calendar.java day of week order e.g Sun = 1 ... Sat = 7
    dayOfWeekString = new DateFormatSymbols().getShortWeekdays();

    int numOfButtonsInRow1;
    int numOfButtonsInRow2;

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) {
        // Get screen width in dp first
        Display display = getActivity().getWindowManager().getDefaultDisplay();
        DisplayMetrics outMetrics = new DisplayMetrics();
        display.getMetrics(outMetrics);

        float density = getResources().getDisplayMetrics().density;
        float dpWidth = outMetrics.widthPixels / density;
        if (dpWidth > MIN_SCREEN_WIDTH_FOR_SINGLE_ROW_WEEK) {
            numOfButtonsInRow1 = 7;
            numOfButtonsInRow2 = 0;
            mWeekGroup2.setVisibility(View.GONE);
            mWeekGroup2.getChildAt(3).setVisibility(View.GONE);
        } else {
            numOfButtonsInRow1 = 4;
            numOfButtonsInRow2 = 3;

            mWeekGroup2.setVisibility(View.VISIBLE);
            // Set rightmost button on the second row invisible so it takes up
            // space and everything centers properly
            mWeekGroup2.getChildAt(3).setVisibility(View.INVISIBLE);
        }
    } else if (mResources.getConfiguration().screenWidthDp > MIN_SCREEN_WIDTH_FOR_SINGLE_ROW_WEEK) {
        numOfButtonsInRow1 = 7;
        numOfButtonsInRow2 = 0;
        mWeekGroup2.setVisibility(View.GONE);
        mWeekGroup2.getChildAt(3).setVisibility(View.GONE);
    } else {
        numOfButtonsInRow1 = 4;
        numOfButtonsInRow2 = 3;

        mWeekGroup2.setVisibility(View.VISIBLE);
        // Set rightmost button on the second row invisible so it takes up
        // space and everything centers properly
        mWeekGroup2.getChildAt(3).setVisibility(View.INVISIBLE);
    }

    /* First row */
    for (int i = 0; i < 7; i++) {
        if (i >= numOfButtonsInRow1) {
            mWeekGroup.getChildAt(i).setVisibility(View.GONE);
            continue;
        }

        mWeekByDayButtons[idx] = (ToggleButton) mWeekGroup.getChildAt(i);
        mWeekByDayButtons[idx].setTextOff(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setTextOn(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setOnCheckedChangeListener(this);

        if (++idx >= 7) {
            idx = 0;
        }
    }

    /* 2nd Row */
    for (int i = 0; i < 3; i++) {
        if (i >= numOfButtonsInRow2) {
            mWeekGroup2.getChildAt(i).setVisibility(View.GONE);
            continue;
        }
        mWeekByDayButtons[idx] = (ToggleButton) mWeekGroup2.getChildAt(i);
        mWeekByDayButtons[idx].setTextOff(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setTextOn(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setOnCheckedChangeListener(this);

        if (++idx >= 7) {
            idx = 0;
        }
    }

    mMonthGroup = (LinearLayout) mView.findViewById(R.id.monthGroup);
    mMonthRepeatByRadioGroup = (RadioGroup) mView.findViewById(R.id.monthGroup);
    mMonthRepeatByRadioGroup.setOnCheckedChangeListener(this);
    mRepeatMonthlyByNthDayOfWeek = (RadioButton) mView.findViewById(R.id.repeatMonthlyByNthDayOfTheWeek);
    mRepeatMonthlyByNthDayOfMonth = (RadioButton) mView.findViewById(R.id.repeatMonthlyByNthDayOfMonth);

    mDoneButton = (Button) mView.findViewById(R.id.done_button);
    mDoneButton.setOnClickListener(this);

    Button cancelButton = (Button) mView.findViewById(R.id.cancel_button);
    //FIXME no text color for this one ?
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });

    togglePickerOptions();
    updateDialog();
    if (endCountHasFocus) {
        mEndCount.requestFocus();
    }
    return mView;
}

From source file:com.appeaser.sublimepickerlibrary.recurrencepicker.RecurrenceOptionCreator.java

void initializeLayout() {
    int weekButtonUnselectedTextColor, weekButtonSelectedTextColor, weekButtonSelectedCircleColor;

    final TypedArray a = getContext().obtainStyledAttributes(R.styleable.RecurrenceOptionCreator);
    try {// w  ww  .j a  v  a2  s .  co  m
        mHeaderBackgroundColor = a.getColor(R.styleable.RecurrenceOptionCreator_spHeaderBackground, 0);

        int endDateFormat = a.getInt(R.styleable.RecurrenceOptionCreator_spEndDateFormat, 1);

        mEndDateFormatter = DateFormat.getDateInstance(
                endDateFormat == 0 ? DateFormat.SHORT : DateFormat.MEDIUM, Locale.getDefault());

        weekButtonUnselectedTextColor = a.getColor(
                R.styleable.RecurrenceOptionCreator_spWeekButtonUnselectedTextColor, SUtils.COLOR_ACCENT);
        weekButtonSelectedTextColor = a.getColor(
                R.styleable.RecurrenceOptionCreator_spWeekButtonSelectedTextColor,
                SUtils.COLOR_TEXT_PRIMARY_INVERSE);
        weekButtonSelectedCircleColor = a.getColor(
                R.styleable.RecurrenceOptionCreator_spWeekButtonSelectedCircleColor, SUtils.COLOR_ACCENT);
    } finally {
        a.recycle();
    }

    mResources = getResources();

    LayoutInflater.from(getContext()).inflate(R.layout.recurrence_picker, this);

    mRecurrencePicker = findViewById(R.id.recurrence_picker);

    mDateOnlyPicker = (RecurrenceEndDatePicker) findViewById(R.id.date_only_picker);
    mDateOnlyPicker.setVisibility(View.GONE);

    // OK/Cancel buttons
    mButtonLayout = (DecisionButtonLayout) findViewById(R.id.roc_decision_button_layout);
    mButtonLayout.applyOptions(mButtonLayoutCallback);

    SUtils.setViewBackground(findViewById(R.id.freqSpinnerHolder), mHeaderBackgroundColor,
            SUtils.CORNER_TOP_LEFT | SUtils.CORNER_TOP_RIGHT);

    /** EFrequency Spinner {Repeat daily, Repeat weekly, Repeat monthly, Repeat yearly} **/

    mFreqSpinner = (Spinner) findViewById(R.id.freqSpinner);
    mFreqSpinner.setOnItemSelectedListener(this);

    ArrayAdapter<CharSequence> freqAdapter = ArrayAdapter.createFromResource(getContext(),
            R.array.recurrence_freq, R.layout.roc_freq_spinner_item);
    freqAdapter.setDropDownViewResource(R.layout.roc_spinner_dropdown_item);
    mFreqSpinner.setAdapter(freqAdapter);

    Drawable freqSpinnerBg = ContextCompat.getDrawable(getContext(), R.drawable.abc_spinner_mtrl_am_alpha);
    PorterDuffColorFilter cfFreqSpinner = new PorterDuffColorFilter(SUtils.COLOR_TEXT_PRIMARY_INVERSE,
            PorterDuff.Mode.SRC_IN);
    if (freqSpinnerBg != null) {
        freqSpinnerBg.setColorFilter(cfFreqSpinner);
        SUtils.setViewBackground(mFreqSpinner, freqSpinnerBg);
    }

    mInterval = (EditText) findViewById(R.id.interval);
    mInterval.addTextChangedListener(new minMaxTextWatcher(1, INTERVAL_DEFAULT, INTERVAL_MAX) {
        @Override
        void onChange(int v) {
            if (mIntervalResId != -1 && mInterval.getText().toString().length() > 0) {
                mModel.interval = v;
                updateIntervalText();
                mInterval.requestLayout();
            }
        }
    });
    mIntervalPreText = (TextView) findViewById(R.id.intervalPreText);
    mIntervalPostText = (TextView) findViewById(R.id.intervalPostText);

    /** End Spinner {Forever, Until a date, For a number of events} **/

    mEndNeverStr = mResources.getString(R.string.recurrence_end_continously);
    mEndDateLabel = mResources.getString(R.string.recurrence_end_date_label);
    mEndCountLabel = mResources.getString(R.string.recurrence_end_count_label);

    mEndSpinnerArray.add(mEndNeverStr);
    mEndSpinnerArray.add(mEndDateLabel);
    mEndSpinnerArray.add(mEndCountLabel);
    mEndSpinner = (Spinner) findViewById(R.id.endSpinner);
    mEndSpinner.setOnItemSelectedListener(this);

    mEndSpinnerAdapter = new EndSpinnerAdapter(getContext(), mEndSpinnerArray, R.layout.roc_end_spinner_item,
            R.id.spinner_item, R.layout.roc_spinner_dropdown_item);
    mEndSpinner.setAdapter(mEndSpinnerAdapter);

    mEndCount = (EditText) findViewById(R.id.endCount);
    mEndCount.addTextChangedListener(new minMaxTextWatcher(1, COUNT_DEFAULT, COUNT_MAX) {
        @Override
        void onChange(int v) {
            if (mModel.endCount != v) {
                mModel.endCount = v;
                updateEndCountText();
                mEndCount.requestLayout();
            }
        }
    });
    mPostEndCount = (TextView) findViewById(R.id.postEndCount);

    mEndDateTextView = (TextView) findViewById(R.id.endDate);
    mEndDateTextView.setOnClickListener(this);

    SUtils.setViewBackground(mEndDateTextView,
            SUtils.createButtonBg(getContext(), SUtils.COLOR_BUTTON_NORMAL, SUtils.COLOR_CONTROL_HIGHLIGHT));

    // set default & checked state colors
    WeekButton.setStateColors(weekButtonUnselectedTextColor, weekButtonSelectedTextColor);

    // AOSP code handled this differently. It has been refactored to
    // let Android decide if we have enough space to show
    // all seven 'WeekButtons' inline. In this case, 'mWeekGroup2'
    // will be null (see @layout-w460dp/week_buttons).
    mWeekGroup = (LinearLayout) findViewById(R.id.weekGroup);
    mWeekGroup2 = (LinearLayout) findViewById(R.id.weekGroup2);

    // Only non-null when available width is < 460dp
    // Used only for positioning 'WeekButtons' in two rows
    // of 4 & 3.
    View eighthWeekDay = findViewById(R.id.week_day_8);
    if (eighthWeekDay != null)
        eighthWeekDay.setVisibility(View.INVISIBLE);

    // In Calendar.java day of week order e.g Sun = 1 ... Sat = 7
    //String[] dayOfWeekString = new DateFormatSymbols().getWeekdays();

    mMonthRepeatByDayOfWeekStrs = new String[7][];
    // from Time.SUNDAY as 0 through Time.SATURDAY as 6
    mMonthRepeatByDayOfWeekStrs[0] = mResources.getStringArray(R.array.repeat_by_nth_sun);
    mMonthRepeatByDayOfWeekStrs[1] = mResources.getStringArray(R.array.repeat_by_nth_mon);
    mMonthRepeatByDayOfWeekStrs[2] = mResources.getStringArray(R.array.repeat_by_nth_tues);
    mMonthRepeatByDayOfWeekStrs[3] = mResources.getStringArray(R.array.repeat_by_nth_wed);
    mMonthRepeatByDayOfWeekStrs[4] = mResources.getStringArray(R.array.repeat_by_nth_thurs);
    mMonthRepeatByDayOfWeekStrs[5] = mResources.getStringArray(R.array.repeat_by_nth_fri);
    mMonthRepeatByDayOfWeekStrs[6] = mResources.getStringArray(R.array.repeat_by_nth_sat);

    // In Time.java day of week order e.g. Sun = 0
    int idx = RecurrenceUtils.getFirstDayOfWeek();

    // In Calendar.java day of week order e.g Sun = 1 ... Sat = 7
    String[] dayOfWeekString = new DateFormatSymbols().getShortWeekdays();

    // CheckableDrawable's width & height
    int expandedWidthHeight = mResources.getDimensionPixelSize(R.dimen.week_button_state_on_circle_size);

    WeekButton[] tempWeekButtons = new WeekButton[7];
    tempWeekButtons[0] = (WeekButton) findViewById(R.id.week_day_1);
    tempWeekButtons[1] = (WeekButton) findViewById(R.id.week_day_2);
    tempWeekButtons[2] = (WeekButton) findViewById(R.id.week_day_3);
    tempWeekButtons[3] = (WeekButton) findViewById(R.id.week_day_4);
    tempWeekButtons[4] = (WeekButton) findViewById(R.id.week_day_5);
    tempWeekButtons[5] = (WeekButton) findViewById(R.id.week_day_6);
    tempWeekButtons[6] = (WeekButton) findViewById(R.id.week_day_7);

    for (int i = 0; i < mWeekByDayButtons.length; i++) {
        mWeekByDayButtons[idx] = tempWeekButtons[i];
        SUtils.setViewBackground(mWeekByDayButtons[idx],
                new CheckableDrawable(weekButtonSelectedCircleColor, false, expandedWidthHeight));
        mWeekByDayButtons[idx].setTextColor(weekButtonUnselectedTextColor);
        mWeekByDayButtons[idx].setTextOff(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setTextOn(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setOnCheckedChangeListener(this);

        if (++idx >= 7) {
            idx = 0;
        }
    }

    mMonthRepeatByRadioGroup = (RadioGroup) findViewById(R.id.monthGroup);
    mMonthRepeatByRadioGroup.setOnCheckedChangeListener(this);
    mRepeatMonthlyByNthDayOfWeek = (RadioButton) findViewById(R.id.repeatMonthlyByNthDayOfTheWeek);
    mRepeatMonthlyByNthDayOfMonth = (RadioButton) findViewById(R.id.repeatMonthlyByNthDayOfMonth);
}

From source file:reportsas.com.formulapp.Formulario.java

public LinearLayout obtenerLayout(LayoutInflater infla, Pregunta preg) {
    int id;/*from   w  w w . ja v a 2  s  .co  m*/
    int tipo_pregunta = preg.getTipoPregunta();
    LinearLayout pregunta;
    TextView textView;
    TextView textAyuda;
    switch (tipo_pregunta) {
    case 1:
        id = R.layout.pregunta_texto;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloPregunta);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        break;
    case 2:
        id = R.layout.pregunta_multitexto;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.mtxtTritulo);
        textAyuda = (TextView) pregunta.findViewById(R.id.mtxtAyuda);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());

        break;
    case 3:
        id = R.layout.pregunta_seleccion;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloSeleccion);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_seleccion);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        RadioGroup rg = (RadioGroup) pregunta.findViewById(R.id.opcionesUnica);
        ArrayList<OpcionForm> opciones = preg.getOpciones();
        final ArrayList<RadioButton> rb = new ArrayList<RadioButton>();

        for (int i = 0; i < opciones.size(); i++) {
            OpcionForm opcion = opciones.get(i);
            rb.add(new RadioButton(this));
            rg.addView(rb.get(i));
            rb.get(i).setText(opcion.getEtInicial());

        }
        final TextView respt = (TextView) pregunta.findViewById(R.id.respuestaGruop);
        rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                int radioButtonID = group.getCheckedRadioButtonId();
                RadioButton radioButton = (RadioButton) group.findViewById(radioButtonID);
                respt.setText(radioButton.getText());
            }
        });

        break;
    case 4:
        id = R.layout.pregunta_multiple;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloMultiple);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_mltiple);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        ArrayList<OpcionForm> opciones2 = preg.getOpciones();
        final EditText ediOtros = new EditText(this);
        ArrayList<CheckBox> cb = new ArrayList<CheckBox>();

        for (int i = 0; i < opciones2.size(); i++) {
            OpcionForm opcion = opciones2.get(i);
            cb.add(new CheckBox(this));
            pregunta.addView(cb.get(i));
            cb.get(i).setText(opcion.getEtInicial());
            if (opcion.getEditble().equals("S")) {

                ediOtros.setEnabled(false);
                ediOtros.setId(R.id.edtTexto);
                pregunta.addView(ediOtros);
                cb.get(i).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        if (isChecked) {
                            ediOtros.setEnabled(true);
                        } else {
                            ediOtros.setText("");
                            ediOtros.setEnabled(false);
                        }
                    }
                });
            }

        }
        TextView spacio = new TextView(this);
        spacio.setText("        ");
        spacio.setVisibility(View.INVISIBLE);
        pregunta.addView(spacio);
        break;
    case 5:
        id = R.layout.pregunta_escala;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloEscala);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_escala);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());

        TextView etInicial = (TextView) pregunta.findViewById(R.id.etInicial);
        TextView etFinal = (TextView) pregunta.findViewById(R.id.etFinal);
        OpcionForm opci = preg.getOpciones().get(0);
        etInicial.setText(opci.getEtInicial());
        etFinal.setText(opci.getEtFinal());
        final TextView respEscala = (TextView) pregunta.findViewById(R.id.seleEscala);
        RatingBar rtBar = (RatingBar) pregunta.findViewById(R.id.escala);
        rtBar.setNumStars(Integer.parseInt(opci.getValores().get(0).getDescripcion()));
        rtBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
            @Override
            public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
                respEscala.setText("" + Math.round(rating));
            }
        });

        break;
    case 6:
        id = R.layout.pregunta_lista;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloLista);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_lista);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        ArrayList<OpcionForm> opciones3 = preg.getOpciones();
        //Creamos la lista
        LinkedList<ObjetoSpinner> opcn = new LinkedList<ObjetoSpinner>();
        //La poblamos con los ejemplos
        for (int i = 0; i < opciones3.size(); i++) {
            opcn.add(new ObjetoSpinner(opciones3.get(i).getIdOpcion(), opciones3.get(i).getEtInicial()));
        }

        //Creamos el adaptador*/
        Spinner listad = (Spinner) pregunta.findViewById(R.id.opcionesListado);
        ArrayAdapter<ObjetoSpinner> spinner_adapter = new ArrayAdapter<ObjetoSpinner>(this,
                android.R.layout.simple_spinner_item, opcn);
        //Aadimos el layout para el men y se lo damos al spinner
        spinner_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        listad.setAdapter(spinner_adapter);

        break;
    case 7:
        id = R.layout.pregunta_tabla;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloTabla);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_tabla);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        TableLayout tba = (TableLayout) pregunta.findViewById(R.id.tablaOpciones);
        ArrayList<OpcionForm> opciones4 = preg.getOpciones();
        ArrayList<RadioButton> radiosbotonoes = new ArrayList<RadioButton>();
        for (int i = 0; i < opciones4.size(); i++) {
            TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.row_pregunta_tabla, null);
            RadioGroup tg_valores = (RadioGroup) row.findViewById(R.id.valoresRow);

            final ArrayList<RadioButton> valoOpc = new ArrayList<RadioButton>();
            ArrayList<Valor> valoresT = opciones4.get(i).getValores();
            for (int k = 0; k < valoresT.size(); k++) {
                RadioButton rb_nuevo = new RadioButton(this);
                rb_nuevo.setText(valoresT.get(k).getDescripcion());
                tg_valores.addView(rb_nuevo);
                valoOpc.add(rb_nuevo);
            }

            ((TextView) row.findViewById(R.id.textoRow)).setText(opciones4.get(i).getEtInicial());
            tba.addView(row);
        }
        TextView espacio = new TextView(this);
        espacio.setText("        ");
        pregunta.addView(espacio);
        break;
    case 8:
        id = R.layout.pregunta_fecha;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloFecha);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_fecha);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());

        break;
    case 9:
        id = R.layout.pregunta_hora;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloHora);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_hora);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());

        break;
    default:
        id = R.layout.pregunta_multiple;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloMultiple);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_mltiple);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        break;
    }

    return pregunta;
}

From source file:com.aniruddhc.acemusic.player.EqualizerActivity.EqualizerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    //Context./*  www.  j  a  v  a2 s.  c  o  m*/
    mContext = getApplicationContext();
    mApp = (Common) mContext.getApplicationContext();
    mFragment = this;

    setTheme();
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_equalizer);

    //Equalizer container elements.
    mScrollView = (ScrollView) findViewById(R.id.equalizerScrollView);
    mScrollView.setBackgroundColor(UIElementsHelper.getBackgroundColor(mContext));

    //50Hz equalizer controls.
    equalizer50HzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer50Hz);
    text50HzGainTextView = (TextView) findViewById(R.id.text50HzGain);
    text50Hz = (TextView) findViewById(R.id.text50Hz);

    //130Hz equalizer controls.
    equalizer130HzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer130Hz);
    text130HzGainTextView = (TextView) findViewById(R.id.text130HzGain);
    text130Hz = (TextView) findViewById(R.id.text130Hz);

    //320Hz equalizer controls.
    equalizer320HzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer320Hz);
    text320HzGainTextView = (TextView) findViewById(R.id.text320HzGain);
    text320Hz = (TextView) findViewById(R.id.text320Hz);

    //800Hz equalizer controls.
    equalizer800HzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer800Hz);
    text800HzGainTextView = (TextView) findViewById(R.id.text800HzGain);
    text800Hz = (TextView) findViewById(R.id.text800Hz);

    //2kHz equalizer controls.
    equalizer2kHzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer2kHz);
    text2kHzGainTextView = (TextView) findViewById(R.id.text2kHzGain);
    text2kHz = (TextView) findViewById(R.id.text2kHz);

    //5kHz equalizer controls.
    equalizer5kHzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer5kHz);
    text5kHzGainTextView = (TextView) findViewById(R.id.text5kHzGain);
    text5kHz = (TextView) findViewById(R.id.text5kHz);

    //12.5kHz equalizer controls.
    equalizer12_5kHzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer12_5kHz);
    text12_5kHzGainTextView = (TextView) findViewById(R.id.text12_5kHzGain);
    text12_5kHz = (TextView) findViewById(R.id.text12_5kHz);

    //Equalizer preset controls.
    loadPresetButton = (RelativeLayout) findViewById(R.id.loadPresetButton);
    saveAsPresetButton = (RelativeLayout) findViewById(R.id.saveAsPresetButton);
    resetAllButton = (RelativeLayout) findViewById(R.id.resetAllButton);
    loadPresetText = (TextView) findViewById(R.id.load_preset_text);
    savePresetText = (TextView) findViewById(R.id.save_as_preset_text);
    resetAllText = (TextView) findViewById(R.id.reset_all_text);

    //Audio FX elements.
    virtualizerSeekBar = (SeekBar) findViewById(R.id.virtualizer_seekbar);
    bassBoostSeekBar = (SeekBar) findViewById(R.id.bass_boost_seekbar);
    reverbSpinner = (Spinner) findViewById(R.id.reverb_spinner);
    virtualizerTitle = (TextView) findViewById(R.id.virtualizer_title_text);
    bassBoostTitle = (TextView) findViewById(R.id.bass_boost_title_text);
    reverbTitle = (TextView) findViewById(R.id.reverb_title_text);

    text50HzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text130HzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text320HzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text800HzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text2kHzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text5kHzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text12_5kHzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text50Hz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text130Hz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text320Hz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text800Hz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text2kHz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text5kHz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text12_5kHz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));

    loadPresetText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Bold"));
    savePresetText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Bold"));
    resetAllText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Bold"));

    text50HzGainTextView.setPaintFlags(
            text50HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text130HzGainTextView.setPaintFlags(
            text130HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text320HzGainTextView.setPaintFlags(
            text320HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text800HzGainTextView.setPaintFlags(
            text130HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text2kHzGainTextView.setPaintFlags(
            text320HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text5kHzGainTextView.setPaintFlags(
            text130HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text12_5kHzGainTextView.setPaintFlags(
            text320HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text50Hz.setPaintFlags(text50Hz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text130Hz.setPaintFlags(text130Hz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text320Hz.setPaintFlags(text320Hz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text800Hz.setPaintFlags(text800Hz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text2kHz.setPaintFlags(text2kHz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text5kHz.setPaintFlags(text5kHz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text12_5kHz.setPaintFlags(text12_5kHz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);

    loadPresetText.setPaintFlags(
            text50HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    savePresetText.setPaintFlags(
            text50HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    resetAllText.setPaintFlags(
            text50HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);

    text50HzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text130HzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text320HzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text800HzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text2kHzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text5kHzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text12_5kHzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text50Hz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text130Hz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text320Hz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text800Hz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text2kHz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text5kHz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text12_5kHz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));

    //Init reverb presets.
    ArrayList<String> reverbPresets = new ArrayList<String>();
    reverbPresets.add("None");
    reverbPresets.add("Large Hall");
    reverbPresets.add("Large Room");
    reverbPresets.add("Medium Hall");
    reverbPresets.add("Medium Room");
    reverbPresets.add("Small Room");
    reverbPresets.add("Plate");

    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            reverbPresets);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    reverbSpinner.setAdapter(dataAdapter);

    //Set the max values for the seekbars.
    virtualizerSeekBar.setMax(1000);
    bassBoostSeekBar.setMax(1000);

    virtualizerTitle.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    virtualizerTitle.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    virtualizerTitle
            .setPaintFlags(virtualizerTitle.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    bassBoostTitle.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    bassBoostTitle.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    bassBoostTitle
            .setPaintFlags(bassBoostTitle.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    reverbTitle.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    reverbTitle.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    reverbTitle.setPaintFlags(reverbTitle.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    resetAllButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            //Reset all sliders to 0.
            equalizer50HzSeekBar.setProgressAndThumb(16);
            equalizer130HzSeekBar.setProgressAndThumb(16);
            equalizer320HzSeekBar.setProgressAndThumb(16);
            equalizer800HzSeekBar.setProgressAndThumb(16);
            equalizer2kHzSeekBar.setProgressAndThumb(16);
            equalizer5kHzSeekBar.setProgressAndThumb(16);
            equalizer12_5kHzSeekBar.setProgressAndThumb(16);
            virtualizerSeekBar.setProgress(0);
            bassBoostSeekBar.setProgress(0);
            reverbSpinner.setSelection(0, false);

            //Apply the new setings to the service.
            applyCurrentEQSettings();

            //Show a confirmation toast.
            Toast.makeText(mContext, R.string.eq_reset, Toast.LENGTH_SHORT).show();

        }

    });

    loadPresetButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            buildLoadPresetDialog().show();

        }

    });

    saveAsPresetButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            buildSavePresetDialog().show();

        }

    });

    equalizer50HzSeekBar.setOnSeekBarChangeListener(equalizer50HzListener);
    equalizer130HzSeekBar.setOnSeekBarChangeListener(equalizer130HzListener);
    equalizer320HzSeekBar.setOnSeekBarChangeListener(equalizer320HzListener);
    equalizer800HzSeekBar.setOnSeekBarChangeListener(equalizer800HzListener);
    equalizer2kHzSeekBar.setOnSeekBarChangeListener(equalizer2kHzListener);
    equalizer5kHzSeekBar.setOnSeekBarChangeListener(equalizer5kHzListener);
    equalizer12_5kHzSeekBar.setOnSeekBarChangeListener(equalizer12_5kHzListener);

    virtualizerSeekBar.setOnSeekBarChangeListener(virtualizerListener);
    bassBoostSeekBar.setOnSeekBarChangeListener(bassBoostListener);
    reverbSpinner.setOnItemSelectedListener(reverbListener);

    //Get the saved equalizer settings and apply them to the UI elements.
    new AsyncInitSlidersTask().execute();

}

From source file:com.gpsmobitrack.gpstracker.MenuItems.SettingsPage.java

/**
 * Create spinner for update duration//from  w  ww  . j  av a 2  s  .c o  m
 */
private void createUpdateSpinner() {
    //ArrayAdapter<String> spinAdap = new ArrayAdapter<String>(ctn, android.R.layout.simple_spinner_item, state);
    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getActivity(), R.layout.settings_spinner_view,
            updateDurationText);
    //ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_single_choice);
    /*for(int i =0;i<updateDurationText.length;i++){
       arrayAdapter.add(updateDurationText[i]+" Min");
    }*/
    arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    updateSpinner.setAdapter(arrayAdapter);
}