Example usage for android.widget SeekBar setOnSeekBarChangeListener

List of usage examples for android.widget SeekBar setOnSeekBarChangeListener

Introduction

In this page you can find the example usage for android.widget SeekBar setOnSeekBarChangeListener.

Prototype

public void setOnSeekBarChangeListener(OnSeekBarChangeListener l) 

Source Link

Document

Sets a listener to receive notifications of changes to the SeekBar's progress level.

Usage

From source file:com.esri.arcgisruntime.sample.hillshaderenderer.ParametersDialogFragment.java

/**
 * Builds a parameter dialog box with values pulled through from MainActivity.
 * @param savedInstanceState bundle holding previous activity's saved state
 * @return create parameter dialog box//from  w w  w .j  av  a  2s  . co  m
 */
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    Bundle hillshadeParameters = getArguments();
    if (hillshadeParameters != null) {
        mAltitude = hillshadeParameters.getInt("altitude");
        mAzimuth = hillshadeParameters.getInt("azimuth");
        mSlopeType = (SlopeType) hillshadeParameters.getSerializable("slope_type");
    }

    AlertDialog.Builder paramDialog = new AlertDialog.Builder(getContext());
    @SuppressLint("InflateParams")
    View dialogView = inflater.inflate(R.layout.hillshade_dialog_box, null);
    paramDialog.setView(dialogView);
    paramDialog.setTitle(R.string.dialog_title);
    paramDialog.setNegativeButton("Cancel", (dialog, which) -> dismiss());
    paramDialog.setPositiveButton("Render", (dialog, which) -> {
        ParametersListener activity = (ParametersListener) getActivity();
        activity.returnParameters(mAltitude, mAzimuth, mSlopeType);
    });

    mCurrAltitudeTextView = dialogView.findViewById(R.id.hillshade_curr_altitude_text);
    SeekBar altitudeSeekBar = dialogView.findViewById(R.id.hillshade_altitude_seek_bar);
    altitudeSeekBar.setMax(90); //altitude is restricted to 0 - 90
    //set initial altitude value
    updateAltitudeSeekBar(altitudeSeekBar);
    altitudeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mAltitude = progress;
            updateAltitudeSeekBar(seekBar);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });

    mCurrAzimuthTextView = dialogView.findViewById(R.id.hillshade_curr_azimuth_text);
    SeekBar azimuthSeekBar = dialogView.findViewById(R.id.hillshade_azimuth_seek_bar);
    azimuthSeekBar.setMax(360); //azimuth measured in degrees 0 - 360
    //set initial azimuth value
    updateAzimuthSeekBar(azimuthSeekBar);
    azimuthSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mAzimuth = progress;
            updateAzimuthSeekBar(seekBar);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });

    List<String> slopeTypeArray = new ArrayList<>();
    slopeTypeArray.add("None"); //ordinals:0
    slopeTypeArray.add("Degree"); //1
    slopeTypeArray.add("Percent rise"); //2
    slopeTypeArray.add("Scaled"); //3

    ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getContext(), R.layout.hillshade_spinner_text_view,
            slopeTypeArray);

    Spinner slopeTypeSpinner = dialogView.findViewById(R.id.hillshade_slope_type_spinner);
    slopeTypeSpinner.setAdapter(spinnerAdapter);
    slopeTypeSpinner.setSelection(mSlopeType.ordinal());
    slopeTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                mSlopeType = SlopeType.NONE;
                break;
            case 1:
                mSlopeType = SlopeType.DEGREE;
                break;
            case 2:
                mSlopeType = SlopeType.PERCENT_RISE;
                break;
            case 3:
                mSlopeType = SlopeType.SCALED;
                break;
            }
        }

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

    return paramDialog.create();
}

From source file:com.techjoynt.android.nxt.fragment.NXTFragment.java

private void setupUI() {
    ImageButton buttonUp = (ImageButton) getView().findViewById(R.id.button_up);
    buttonUp.setOnTouchListener(new DirectionButtonOnTouchListener(1, 1));
    ImageButton buttonLeft = (ImageButton) getView().findViewById(R.id.button_left);
    buttonLeft.setOnTouchListener(new DirectionButtonOnTouchListener(-0.6, 0.6));
    ImageButton buttonDown = (ImageButton) getView().findViewById(R.id.button_down);
    buttonDown.setOnTouchListener(new DirectionButtonOnTouchListener(-1, -1));
    ImageButton buttonRight = (ImageButton) getView().findViewById(R.id.button_right);
    buttonRight.setOnTouchListener(new DirectionButtonOnTouchListener(0.6, -0.6));

    SeekBar powerSeekBar = (SeekBar) getView().findViewById(R.id.power_seekbar);
    powerSeekBar.setProgress(mPower);/* w  ww.j  av a2 s .c om*/
    powerSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mPower = progress;
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });

    mStateDisplay = (TextView) getView().findViewById(R.id.state_display);

    mConnectButton = (Button) getView().findViewById(R.id.connect_button);
    mConnectButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!NO_BT) {
                findBrick();
            } else {
                mState = NXTTalker.STATE_CONNECTED;
                displayState();
            }
        }
    });

    mDisconnectButton = (Button) getView().findViewById(R.id.disconnect_button);
    mDisconnectButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mNXTTalker.stop();
        }
    });

    displayState();
}

From source file:org.alfresco.mobile.android.application.extension.samsung.pen.SNotePagesDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    getDialog().setTitle(R.string.editor_pages_move);
    getDialog().requestWindowFeature(Window.FEATURE_LEFT_ICON);

    ViewGroup v = (ViewGroup) inflater.inflate(R.layout.snote_pages, container, false);

    int width = (int) Math.round(UIUtils.getScreenDimension(getActivity())[0] * (Float.parseFloat(
            getResources().getString(android.R.dimen.dialog_min_width_major).replace("%", "")) * 0.01));
    v.setLayoutParams(new LayoutParams(width, LayoutParams.MATCH_PARENT));

    final SeekBar seekbar = ((SeekBar) v.findViewById(R.id.seekbar_pages));
    final TextView tv = ((TextView) v.findViewById(R.id.pages_number));
    tv.setText(String.valueOf(originPageNumber + 1) + " / " + String.valueOf(totalPages));

    seekbar.setMax(totalPages - 1);/*from   w  w w  .java2  s .  c om*/
    seekbar.setProgress(originPageNumber);
    seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            currentPageNumber = progress + 1;
            tv.setText(String.valueOf(currentPageNumber) + " / " + String.valueOf(totalPages));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });

    final Button validate = (Button) v.findViewById(R.id.create_document);
    final Button cancel = (Button) v.findViewById(R.id.cancel);

    validate.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            ((SNoteEditorActivity) getActivity()).movePage(currentPageNumber - 1);
            dismiss();
        }
    });

    cancel.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            SNotePagesDialogFragment.this.dismiss();
        }
    });

    return v;
}

From source file:de.tu_darmstadt.kom.freifunkfinder.user_interface.MainActivity.java

/**
 * MainActivity's.onCreate method, set listeners of all configurable items.
 *
 * @param savedInstanceState Saved instance state bundle.
 */// w w  w.  j av a2 s .co m
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // shared pref operation
    SharedPreferences sharedPreferences = getSharedPreferences(FreifunkFinderAppConstants.PREFS_TIMESTAMP, 0);
    long oldTimestamp = sharedPreferences.getLong(FreifunkFinderAppConstants.PREFERENC_KEY, 0L);
    Log.d(DEBUG_TAG, "Old timestamp received = " + oldTimestamp);
    GlobalParams.setOldTimeStamp(oldTimestamp);

    /*<<<<<<< HEAD:app/src/main/java/de/tu_darmstadt/kom/freifunkfinder/user_interface/MainActivity.java
            //Initialize toolbar options
    =======
            
    >>>>>>> debf605494804f586b7d98939b55c59832800612:src/main/java/de/tu_darmstadt/kom/freifunkfinder/user_interface/MainActivity.java
    */ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    //Set loading progressbar invisible on startup
    progressBar = (ProgressBar) findViewById(R.id.progress_bar);
    progressBar.setVisibility(View.INVISIBLE);
    progressBarTxt = (TextView) findViewById(R.id.progress_bar_txt);
    progressBarTxt.setVisibility(View.INVISIBLE);

    //MobileLocationManageer instantiation
    mobileLocationManager = new MobileLocationManager(getApplicationContext(), MainActivity.this);
    mobileLocationManager.initLocation();

    //WifiFinderApplication instantiation
    wifiFinderApplication = WifiFinderApplication.getWifiFinderApplication(getApplicationContext());

    //JSON read, need location info for this
    JsonReaderAsyncTask jsonReaderAsyncTask = new JsonReaderAsyncTask();
    jsonReaderAsyncTask.execute();

    //WifiOverlay instantiation
    wifiOverlayView = new WifiOverlayView(getApplicationContext(), this, mobileLocationManager);

    //CameraView instantiation
    cameraView = new CameraView(getApplicationContext(), MainActivity.this);

    //FrameLayout instantiation
    arView = (FrameLayout) findViewById(R.id.ar_view);
    button = (Button) findViewById(R.id.button);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            arView.addView(cameraView);
            arView.addView(wifiOverlayView);
            view.setVisibility(View.INVISIBLE);
            if (!GlobalParams.isWifiNodesPersisted()) {
                progressBar.setVisibility(View.VISIBLE);
                progressBarTxt.setVisibility(View.VISIBLE);
            }
            isOverlayView = true;
        }
    });

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    final TextView seekTextView = (TextView) findViewById(R.id.seekTextView);

    //seek bar listener for saving user selected distance
    final SeekBar seekBar = (SeekBar) findViewById(R.id.seekBar);
    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        int distance;
        Double lookupDistance = 999.000;

        @Override
        public void onProgressChanged(SeekBar seekBar, int progresValue, boolean fromUser) {
            isParamChanged = true;
            distance = (progresValue * 2000 / seekBar.getMax());
            GlobalParams.setSearchRange(distance);
            lookupDistance = (distance < 999 ? ((double) distance) : (distance / 1000.00));
            seekTextView.setText("Distnce : " + String.format("%.2f", lookupDistance) + " "
                    + (distance < 999 ? "Meters" : "Kilometers"));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            isParamChanged = true;
            distance = (seekBar.getProgress() * 2000 / seekBar.getMax());
            GlobalParams.setSearchRange(distance);
            lookupDistance = (distance < 999 ? ((double) distance) : (distance / 1000.00));
            seekTextView.setText("Distnce : " + String.format("%.2f", lookupDistance) + " "
                    + (distance < 999 ? "Meters" : "Kilometers"));
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            isParamChanged = true;
            distance = (seekBar.getProgress() * 2000 / seekBar.getMax());
            GlobalParams.setSearchRange(distance);
            lookupDistance = (distance < 999 ? ((double) distance) : (distance / 1000.00));
            seekTextView.setText("Distnce : " + String.format("%.2f", lookupDistance) + " "
                    + (distance < 999 ? "Meters" : "Kilometers"));
        }
    });

    //Edit textr listener for saving user selected count
    final EditText editText = (EditText) findViewById(R.id.countView);
    editText.addTextChangedListener(new TextWatcher() {
        int count;

        public void afterTextChanged(Editable s) {
            isParamChanged = true;

            if (!editText.getText().toString().equals("")) {
                count = Integer.parseInt(editText.getText().toString());
                GlobalParams.setNodesCount(count);
            } else {
                GlobalParams.setNodesCount(10);
            }
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });
}

From source file:com.arcusapp.soundbox.fragment.PlayFragment.java

private void initUI(View rootView) {
    txtTitle = (TextView) rootView.findViewById(R.id.txtSongTitle);
    txtTitle.setTypeface(null, Typeface.BOLD);
    txtTitle.setSelected(true);//from www  .  j  a  v  a 2 s. c  o m
    txtArtist = (TextView) rootView.findViewById(R.id.txtSongArtist);
    txtAlbum = (TextView) rootView.findViewById(R.id.txtSongAlbum);
    txtTimeCurrent = (TextView) rootView.findViewById(R.id.txtTimeCurrent);
    txtTimeTotal = (TextView) rootView.findViewById(R.id.txtTimeTotal);

    btnPlayPause = (ImageButton) rootView.findViewById(R.id.btnPlayPause);
    btnPlayPause.setOnClickListener(this);
    btnPrevious = (ImageButton) rootView.findViewById(R.id.btnPrevSong);
    btnPrevious.setOnClickListener(this);
    btnNext = (ImageButton) rootView.findViewById(R.id.btnNextSong);
    btnNext.setOnClickListener(this);
    btnSwitchRandom = (ImageButton) rootView.findViewById(R.id.btnSwitchRandom);
    btnSwitchRandom.setOnClickListener(this);
    btnSwitchRepeat = (ImageButton) rootView.findViewById(R.id.btnSwitchRepeat);
    btnSwitchRepeat.setOnClickListener(this);
    btnPanel = (ImageButton) rootView.findViewById(R.id.btnPanel);
    btnPanel.setOnClickListener(this);

    // init the seekbar
    seekBar = (SeekBar) rootView.findViewById(R.id.seekBar);
    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
                if (mediaService != null) {
                    mediaService.seekTo(progress);
                    seekBar.setProgress(progress);
                }
            }
        }
    });
}

From source file:com.andryr.musicplayer.activities.EqualizerActivity.java

private void initSeekBars() {
    ViewGroup layout = (ViewGroup) findViewById(R.id.equalizer_layout);

    final short[] range = AudioEffects.getBandLevelRange();

    LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, 0, 1);
    short bands = AudioEffects.getNumberOfBands();

    for (short band = 0; band < bands; band++) {

        View v = getLayoutInflater().inflate(R.layout.equalizer_slider, layout, false);

        SeekBar seekBar = (SeekBar) v.findViewById(R.id.seek_bar);

        seekBar.setMax(range[1] - range[0]);

        seekBar.setTag(band);// w  w  w .  j  av a2 s .  c  o  m

        final TextView levelTextView = (TextView) v.findViewById(R.id.level);
        seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

                if (fromUser) {
                    short band = (Short) seekBar.getTag();
                    short level = (short) (seekBar.getProgress() + range[0]);
                    AudioEffects.setBandLevel(band, level);
                    levelTextView.setText((level > 0 ? "+" : "") + level / 100 + "dB");
                    mSpinner.setSelection(0);
                }

            }
        });

        layout.addView(v, band, lp);

    }

}

From source file:com.dycody.android.idealnote.SketchFragment.java

private void showPopup(View anchor, final int eraserOrStroke) {

    boolean isErasing = eraserOrStroke == SketchView.ERASER;

    oldColor = mColorPicker.getColor();// w  w  w  .j  av  a  2s  .  c  o m

    DisplayMetrics metrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);

    // Creating the PopupWindow
    PopupWindow popup = new PopupWindow(getActivity());
    popup.setContentView(isErasing ? popupEraserLayout : popupLayout);
    popup.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
    popup.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
    popup.setFocusable(true);
    popup.setOnDismissListener(() -> {
        if (mColorPicker.getColor() != oldColor)
            mColorPicker.setOldCenterColor(oldColor);
    });

    // Clear the default translucent background
    popup.setBackgroundDrawable(new BitmapDrawable());

    // Displaying the popup at the specified location, + offsets (transformed 
    // dp to pixel to support multiple screen sizes)
    popup.showAsDropDown(anchor);

    // Stroke size seekbar initialization and event managing
    SeekBar mSeekBar;
    mSeekBar = (SeekBar) (isErasing ? popupEraserLayout.findViewById(R.id.stroke_seekbar)
            : popupLayout.findViewById(R.id.stroke_seekbar));
    mSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // When the seekbar is moved a new size is calculated and the new shape
            // is positioned centrally into the ImageView
            setSeekbarProgress(progress, eraserOrStroke);
        }
    });
    int progress = isErasing ? seekBarEraserProgress : seekBarStrokeProgress;
    mSeekBar.setProgress(progress);
}

From source file:com.polkapolka.bluetooth.le.DeviceControlActivity.java

private void readSeek(SeekBar seekBar, final int pos) {
    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override//w  w w .  j a  va  2s.c  om
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            RGBFrame[pos] = progress;
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
            makeChange();

        }
    });
}

From source file:com.quaap.audiometer.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    pref = getApplicationContext().getSharedPreferences("main", MODE_PRIVATE);
    mMeterView = (MeterView) findViewById(R.id.meterLayout);

    mMicLevelReader = new MicLevelReader(this, LevelMethod.dBFS);

    ImageButton show_ctrls = (ImageButton) findViewById(R.id.show_ctrls);
    show_ctrls.setOnClickListener(new View.OnClickListener() {
        @Override//ww  w .  ja  va2s  . com
        public void onClick(View view) {
            ViewSwitcher ctrls = (ViewSwitcher) findViewById(R.id.ctrls);
            ctrls.showNext();
        }
    });
    ImageButton hide_ctrls = (ImageButton) findViewById(R.id.hide_ctrls);
    hide_ctrls.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ViewSwitcher ctrls = (ViewSwitcher) findViewById(R.id.ctrls);
            ctrls.showPrevious();
        }
    });

    final SeekBar scaleCtrl = (SeekBar) findViewById(R.id.scaleCtrl);

    scaleCtrl.setProgress(pref.getInt("scaleCtrl", scaleCtrl.getProgress()));

    setScale();

    scaleCtrl.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
            setScale();
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });

    final ToggleButton onoff = (ToggleButton) findViewById(R.id.toggleButton);

    onoff.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (onoff.isChecked()) {
                if (!startit()) {
                    onoff.setChecked(false);
                }
            } else {
                stopit();
            }
        }
    });

    LevelMethod levM = LevelMethod.valueOf(pref.getString("levelMethod", LevelMethod.dBFS.toString()));

    final Spinner levelType = (Spinner) findViewById(R.id.levelType);
    ArrayAdapter<LevelMethod> levelTypeAdapter = new ArrayAdapter<>(this,
            android.R.layout.simple_spinner_dropdown_item, LevelMethod.values());
    levelType.setAdapter(levelTypeAdapter);

    levelType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            LevelMethod lmeth = (LevelMethod) adapterView.getSelectedItem();
            levelMethodChanged(lmeth);

        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    });

    levelType.setSelection(levelTypeAdapter.getPosition(levM));

    levelMethodChanged((LevelMethod) levelType.getSelectedItem());
    checkMicrophoneAccess();
}

From source file:uwp.cs.edu.parkingtracker.parking.ParkDialogFragment.java

/**
 * Called after onAttach as part of the fragment lifecycle.
 *
 * @param savedInstanceState//from   w ww . ja  v  a  2s  . c  o m
 * @return
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    AlertDialog.Builder votePopup = new AlertDialog.Builder(getActivity());
    votePopup.setTitle("How full is this zone?");

    LinearLayout linear = new LinearLayout(getActivity());
    linear.setOrientation(LinearLayout.VERTICAL);
    SeekBar fullnessSlider = new SeekBar(getActivity());

    fullnessSlider.setMax(4);
    fullnessSlider.setPadding(50, 70, 50, -10);
    final TextView result = new TextView(getActivity());
    result.setPadding(20, 10, 10, 10);
    result.setText("0 %");

    linear.addView(fullnessSlider);
    linear.addView(result);

    votePopup.setView(linear);

    fullnessSlider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        public void onProgressChanged(SeekBar seekBar, int fullness, boolean fromUser) {
            fullnessValue = fullness;
            result.setText(fullness * 25 + "%");
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });

    votePopup.setPositiveButton("Send", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            DatabaseExchange.sendVote(zID, fullnessValue * 25);
            dismiss();
        }
    });
    votePopup.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dismiss();
        }
    });
    return votePopup.create();
}