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:mx.klozz.xperience.tweaker.fragments.CPUAdvanced.java

protected void showDialog(final int curval, final int min, final int step, final int total, final String titlu,
        final String key) {
    final LayoutInflater factory = LayoutInflater.from(context);
    final View voltageDialog = factory.inflate(R.layout.voltage_dialog, null);

    final SeekBar voltageSeek = (SeekBar) voltageDialog.findViewById(R.id.voltageSeek);
    final TextView voltageMeter = (TextView) voltageDialog.findViewById(R.id.voltageMeter);

    voltageMeter.setText(String.valueOf(curval) + " V");
    voltageSeek.setMax(total);/*from  w w w  .j av a 2s  . co m*/
    voltageSeek.setProgress(getNearestStepIndex(curval, vmin, vstep, nvsteps));
    voltageSeek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar sb, int progress, boolean fromUser) {
            if (fromUser) {
                final String volt = Integer.toString(progress * step + min);
                voltageMeter.setText(volt + " V");
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    new AlertDialog.Builder(context).setTitle(titlu).setView(voltageDialog)
            .setPositiveButton(getResources().getString(R.string.ps_volt_save),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            dialog.cancel();
                            final String value = Integer.toString(voltageSeek.getProgress() * step + min);
                            SharedPreferences.Editor editor = mPreferences.edit();
                            editor.putString(key, value).commit();
                            if (key.equals("pref_krait_hi")) {
                                mKraitHi.setSummary(getString(R.string.ps_krait_hi, value));
                                new CMDProcessor().su
                                        .runWaitFor("busybox echo " + value + " > " + KRAIT_HIGH_PATH);
                            } else if (key.equals("pref_krait_lo")) {
                                mKraitLo.setSummary(getString(R.string.ps_krait_lo, value));
                                new CMDProcessor().su
                                        .runWaitFor("busybox echo " + value + " > " + KRAIT_LOWER_PATH);
                            }
                        }
                    })
            .setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.cancel();
                }
            }).create().show();

}

From source file:com.barbrdo.app.activities.UserProfileActivity.java

private void showRadiusDialog(String radius) {
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle);
    LayoutInflater inflater = this.getLayoutInflater();
    View dialogView = inflater.inflate(R.layout.dialog_radius, null);
    dialogBuilder.setView(dialogView);/*from  www.j a  va 2s  .  c  o  m*/

    final TextView textViewRadius = (TextView) dialogView.findViewById(R.id.tv_radius);
    SeekBar seekBarRadius = (SeekBar) dialogView.findViewById(R.id.seekBar_radius);

    seekBarRadius.setProgress(Integer.parseInt(radius.replace(" mi", "")));
    textViewRadius.setText(radius);
    final int stepSize = 5;
    seekBarRadius.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            progress = ((int) Math.round(progress / stepSize)) * stepSize;
            textViewRadius.setText(progress + " mi");
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });

    dialogBuilder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            textViewSearchRadius.setText(textViewRadius.getText().toString());
            dialog.dismiss();
        }
    });

    dialogBuilder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    AlertDialog alertDialog = dialogBuilder.create();
    alertDialog.show();

}

From source file:com.atomjack.vcfp.VideoControllerView.java

private void initControllerView(View v) {
    mPauseButton = (ImageButton) v.findViewById(R.id.pause);
    if (mPauseButton != null) {
        mPauseButton.requestFocus();//from  ww w  . j av  a 2  s .  com
        mPauseButton.setOnClickListener(mPauseListener);
    }

    mFullscreenButton = (ImageButton) v.findViewById(R.id.fullscreen);
    if (mFullscreenButton != null) {
        mFullscreenButton.requestFocus();
        mFullscreenButton.setOnClickListener(mFullscreenListener);
    }

    mMediaOptionsButton = (ImageButton) v.findViewById(R.id.mediaOptions);
    if (mMediaOptionsButton != null) {
        mMediaOptionsButton.setOnClickListener(mMediaOptionsListener);
    }

    mMicButton = (ImageButton) v.findViewById(R.id.mic);
    if (mMicButton != null) {
        mMicButton.setOnClickListener(mMicListener);
    }

    mMediaControllerPosterContainer = (ViewGroup) v.findViewById(R.id.mediaControllerPosterContainer);
    mMediaControllerPosterContainer.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            mPlayer.onPosterContainerTouch(v, event);
            return true;
        }
    });

    mFfwdButton = (ImageButton) v.findViewById(R.id.ffwd);
    if (mFfwdButton != null) {
        mFfwdButton.setOnClickListener(mFfwdListener);
        if (!mFromXml) {
            mFfwdButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
        }
    }

    mRewButton = (ImageButton) v.findViewById(R.id.rew);
    if (mRewButton != null) {
        mRewButton.setOnClickListener(mRewListener);
        if (!mFromXml) {
            mRewButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
        }
    }

    mStopButton = (ImageButton) v.findViewById(R.id.stop);
    if (mStopButton != null) {
        mStopButton.setOnClickListener(mStopListener);
    }

    // By default these are hidden. They will be enabled when setPrevNextListeners() is called
    mNextButton = (ImageButton) v.findViewById(R.id.next);
    if (mNextButton != null && !mFromXml && !mListenersSet) {
        mNextButton.setVisibility(View.GONE);
    }
    mPrevButton = (ImageButton) v.findViewById(R.id.prev);
    if (mPrevButton != null && !mFromXml && !mListenersSet) {
        mPrevButton.setVisibility(View.GONE);
    }

    mPoster = (ImageView) v.findViewById(R.id.poster);
    if (mPosterBitmap != null)
        mPoster.setImageBitmap(mPosterBitmap);

    mBitrateSpinner = (CustomSpinner) v.findViewById(R.id.bitrateSpinner);
    if (mBitrateSpinner != null) {

        mBitrateSpinner.getBackground().setColorFilter(ContextCompat.getColor(mContext, R.color.white),
                PorterDuff.Mode.SRC_ATOP);

        final ArrayList<String> list = new ArrayList<>(
                VoiceControlForPlexApplication.localVideoQualityOptions.keySet());
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(mContext, R.layout.bitrate_dropdown_item,
                list) {
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                TextView textView = (TextView) super.getView(position, convertView, parent);
                textView.setTextColor(ContextCompat.getColor(mContext, R.color.white));
                return textView;
            }

            @Override
            public View getDropDownView(int position, View convertView, ViewGroup parent) {
                TextView textView = (TextView) super.getDropDownView(position, convertView, parent);
                textView.setTextColor(ContextCompat.getColor(mContext,
                        textView.getText().equals(mCurrentVideoQuality) ? R.color.black : R.color.white));
                textView.setBackgroundColor(ContextCompat.getColor(mContext,
                        textView.getText().equals(mCurrentVideoQuality) ? R.color.white
                                : R.color.mediaControllerBackground));
                return textView;
            }
        };
        mBitrateSpinner.setAdapter(adapter);

        mBitrateSpinner.setSelection(list.indexOf(mCurrentVideoQuality), false);

        mBitrateSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                String item = list.get(position);
                // Only notify the activity if the bitrate clicked on is not the current one
                if (mBitrateChangeListener != null && !item.equals(mCurrentVideoQuality)) {
                    hide();
                    mBitrateChangeListener.onBitrateChange(item);
                }
            }

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

            }
        });

        mBitrateSpinner.setSpinnerEventsListener(new CustomSpinner.OnSpinnerEventsListener() {
            @Override
            public void onSpinnerOpened() {
                mBitrateSpinnerIsOpen = true;
            }

            @Override
            public void onSpinnerClosed() {
                mBitrateSpinnerIsOpen = false;
                // hide the controller after 3 seconds
                Message msg = mHandler.obtainMessage(FADE_OUT);
                mHandler.removeMessages(FADE_OUT);
                mHandler.sendMessageDelayed(msg, sDefaultTimeout);
            }
        });

    }

    mProgress = (SeekBar) v.findViewById(R.id.mediacontroller_progress);
    if (mProgress != null) {
        if (mProgress instanceof SeekBar) {
            SeekBar seeker = (SeekBar) mProgress;
            seeker.setOnSeekBarChangeListener(mSeekListener);
        }
        mProgress.setMax(1000);
    }

    mEndTime = (TextView) v.findViewById(R.id.time);
    mCurrentTime = (TextView) v.findViewById(R.id.time_current);
    mFormatBuilder = new StringBuilder();
    mFormatter = new Formatter(mFormatBuilder, Locale.getDefault());

    installPrevNextListeners();
}

From source file:org.notfunnynerd.opencoinmap.MapActivity.java

private void showRadiusDialog() {
    final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
    dialogBuilder.setTitle(R.string.near_you);

    LayoutInflater inflater = getLayoutInflater();
    final View layout = inflater.inflate(R.layout.radius_dialog, null);
    dialogBuilder.setView(layout);//from   w w w.j a  va  2 s .  c  o  m

    final AlertDialog dialog = dialogBuilder.create();
    dialog.show();

    final TextView radiusValue = (TextView) layout.findViewById(R.id.radiusValue);

    ListView listView = (ListView) layout.findViewById(R.id.listPlaces);

    final ArrayList<Place> localPlaces = new ArrayList<Place>();
    final ArrayAdapter<Place> adapter = new ArrayAdapter<Place>(this, android.R.layout.simple_list_item_1,
            localPlaces);

    listView.setAdapter(adapter);

    final SeekBar seekRadius = (SeekBar) layout.findViewById(R.id.seekRadius);

    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
            dialog.dismiss();
            Marker marker = getMarkerFromPlace(localPlaces.get(position));
            mMap.animateCamera(CameraUpdateFactory.newLatLng(marker.getPosition()));
            marker.showInfoWindow();
        }
    });
    seekRadius.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        int current = 0;

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            current = progress;
            radiusValue.setText("" + progress);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            localPlaces.clear();
            for (Place place : getPlacesWithinRadius(current)) {
                localPlaces.add(place);
            }
            adapter.notifyDataSetChanged();

        }
    });

    ((Button) layout.findViewById(R.id.okButton)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

}

From source file:jp.co.rediscovery.firstflight.ConfigFragment.java

/**
 * ??//from w  w w.  ja  v a2 s . c o  m
 * @param root
 */
private void initConfigFlight(final View root) {
    if (DEBUG)
        Log.v(TAG, "initConfigFlight:");
    // 
    mMaxAltitudeLabel = root.findViewById(R.id.max_altitude_textview);
    SeekBar seekbar = root.findViewById(R.id.max_altitude_seekbar);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mMaxAltitude = mFlightController.getMaxAltitude();
    try {
        seekbar.setProgress((int) ((mMaxAltitude.current() - mMaxAltitude.min())
                / (mMaxAltitude.max() - mMaxAltitude.min()) * 1000));
    } catch (final Exception e) {
        seekbar.setProgress(0);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateMaxAltitude(mMaxAltitude.current());
    // 
    // bebop?5-3050km/hr???13.9m/s/300.46[m/s/]
    mMaxTiltLabel = root.findViewById(R.id.max_tilt_textview);
    seekbar = root.findViewById(R.id.max_tilt_seekbar);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mMaxTilt = mFlightController.getMaxTilt();
    try {
        seekbar.setProgress(
                (int) ((mMaxTilt.current() - mMaxTilt.min()) / (mMaxTilt.max() - mMaxTilt.min()) * 1000));
    } catch (final Exception e) {
        seekbar.setProgress(0);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateMaxTilt(mMaxTilt.current());
    // /?
    mMaxVerticalSpeedLabel = root.findViewById(R.id.max_vertical_speed_textview);
    seekbar = root.findViewById(R.id.max_vertical_speed_seekbar);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mMaxVerticalSpeed = mFlightController.getMaxVerticalSpeed();
    try {
        seekbar.setProgress((int) ((mMaxVerticalSpeed.current() - mMaxVerticalSpeed.min())
                / (mMaxVerticalSpeed.max() - mMaxVerticalSpeed.min()) * 1000));
    } catch (final Exception e) {
        seekbar.setProgress(0);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateMaxVerticalSpeed(mMaxVerticalSpeed.current());
    // 
    mMaxRotationSpeedLabel = root.findViewById(R.id.max_rotation_speed_textview);
    seekbar = root.findViewById(R.id.max_rotation_speed_seekbar);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mMaxRotationSpeed = mFlightController.getMaxRotationSpeed();
    try {
        seekbar.setProgress((int) ((mMaxRotationSpeed.current() - mMaxRotationSpeed.min())
                / (mMaxRotationSpeed.max() - mMaxRotationSpeed.min()) * 1000));
    } catch (final Exception e) {
        seekbar.setProgress(0);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateMaxRotationSpeed(mMaxRotationSpeed.current());
}

From source file:jp.co.rediscovery.firstflight.ConfigFragment.java

/**
 * ??//from  ww  w .  j  a v a 2 s .  c  o m
 * @param root
 */
private void initConfigGamepad(final View root) {
    // 
    //      final CheckBox checkbox = (CheckBox)root.findViewById(R.id.usb_driver_checkbox);
    //      checkbox.setChecked(mPref.getBoolean(KEY_GAMEPAD_USE_DRIVER, false));
    //      checkbox.setOnCheckedChangeListener(mOnCheckedChangeListener);
    mGamepadMaxControlValueLabel = root.findViewById(R.id.gamepad_sensitivity_textview);
    SeekBar seekbar = root.findViewById(R.id.gamepad_sensitivity_seekbar);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mGamepadMaxControlValue = mPref.getFloat(APP_CONFIG_KEY_GAMEPAD_SENSITIVITY, 1.0f);
    try {
        seekbar.setProgress((int) (mGamepadMaxControlValue + APP_SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(APP_SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateGamepadMaxControlValue(mGamepadMaxControlValue);
    // X
    mGamepadScaleXLabel = root.findViewById(R.id.gamepad_scale_x_textview);
    seekbar = root.findViewById(R.id.gamepad_scale_seekbar_x);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mGamepadScaleX = mPref.getFloat(APP_CONFIG_KEY_GAMEPAD_SCALE_X, 1.0f);
    try {
        seekbar.setProgress((int) (mGamepadScaleX * APP_SCALE_FACTOR + APP_SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(APP_SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateGamepadScaleX(mGamepadScaleX);
    // Y
    mGamepadScaleYLabel = root.findViewById(R.id.gamepad_scale_y_textview);
    seekbar = root.findViewById(R.id.gamepad_scale_seekbar_y);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mGamepadScaleY = mPref.getFloat(APP_CONFIG_KEY_GAMEPAD_SCALE_Y, 1.0f);
    try {
        seekbar.setProgress((int) (mGamepadScaleY * APP_SCALE_FACTOR + APP_SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(APP_SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateGamepadScaleY(mGamepadScaleY);
    // Z
    mGamepadScaleZLabel = root.findViewById(R.id.gamepad_scale_z_textview);
    seekbar = root.findViewById(R.id.gamepad_scale_seekbar_z);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mGamepadScaleZ = mPref.getFloat(APP_CONFIG_KEY_GAMEPAD_SCALE_Z, 1.0f);
    try {
        seekbar.setProgress((int) (mGamepadScaleZ * APP_SCALE_FACTOR + APP_SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(APP_SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateGamepadScaleZ(mGamepadScaleZ);
    // R
    mGamepadScaleRLabel = root.findViewById(R.id.gamepad_scale_r_textview);
    seekbar = root.findViewById(R.id.gamepad_scale_seekbar_r);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mGamepadScaleR = mPref.getFloat(APP_CONFIG_KEY_GAMEPAD_SCALE_R, 1.0f);
    try {
        seekbar.setProgress((int) (mGamepadScaleR * APP_SCALE_FACTOR + APP_SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(APP_SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateGamepadScaleR(mGamepadScaleR);
}

From source file:re.serialout.MainScreen.java

public void setUpFreqSlider() {
    //sets up the freq slider.
    SeekBar seekBar = (SeekBar) findViewById(R.id.freqSeekBar);
    final TextView freqView = (TextView) findViewById(R.id.freqtext);
    seekBar.setProgress((int) 0.6 * seekBar.getProgress());
    seekBar.setMax(10000);//from w  ww. j ava  2  s.co  m
    seekBar.setProgress(4000);
    freqView.setText("Frequency: " + (10000 + 4000));
    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            System.out.println("Current freq: " + (10000 + progress));
            freqView.setText("Frequency: " + (10000 + progress));
            playSine.adjustFreq(10000 + progress);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

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

From source file:oyagev.projects.android.ArduCopter.BluetoothChat.java

private void addControl(String name, String type, int commandValue) {

    Log.d(TAG, "Adding cmd: " + commandValue);

    LinearLayout row = new LinearLayout(this);
    row.setOrientation(LinearLayout.HORIZONTAL);
    row.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));

    View view = new TextView(this);

    //hidden view for command value
    TextView cmdView = new TextView(this);
    cmdView.setLayoutParams(new LinearLayout.LayoutParams(0, 0));
    cmdView.setVisibility(View.INVISIBLE);
    cmdView.setText(String.valueOf(commandValue));
    cmdView.setTag("cmd");

    //Setup the control
    if (type.equals("Button")) {
        view = new Button(this);

        ((Button) view).setText(name);
        ((Button) view).setOnClickListener(new OnClickListener() {

            @Override//  ww  w.  j  a va 2 s.  c  om
            public void onClick(View v) {
                TextView cmd = (TextView) ((LinearLayout) v.getParent()).findViewWithTag("cmd");

                dispatchUserEvent((int) Integer.valueOf(cmd.getText().toString()), new byte[] { 1 });

            }
        });
    } else if (type.equals("Edit")) {
        view = new EditText(this);

        ((EditText) view).setText(name);
    } else if (type.equals("Label")) {
        view = new TextView(this);

        ((TextView) view).setText(name);
    } else if (type.equals("Scrollbar")) {
        view = new LinearLayout(this);

        TextView text = new TextView(this);
        text.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        text.setText(name);
        text.setTag("seek_text");
        SeekBar bar = new SeekBar(this);
        bar.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));

        ((LinearLayout) view).setOrientation(LinearLayout.VERTICAL);

        ((LinearLayout) view).addView(text);
        ((LinearLayout) view).addView(bar);

        bar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

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

            }

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

            }

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

                TextView cmd = (TextView) ((LinearLayout) ((LinearLayout) seekBar.getParent()).getParent())
                        .findViewWithTag("cmd");

                ByteBuffer buffer = ByteBuffer.allocate(2);
                buffer.putShort((short) progress);

                dispatchUserEvent((int) Integer.valueOf(cmd.getText().toString()), buffer.array());

            }
        });
    } else if (type.equals("Input String")) {
        view = new LinearLayout(this);

        TextView text = new TextView(this);
        text.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        text.setText(name);
        text.setTag("inp_text");
        TextView inp = new TextView(this);
        inp.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));

        //((LinearLayout)view).setOrientation(LinearLayout.VERTICAL);

        ((LinearLayout) view).addView(text);
        ((LinearLayout) view).addView(inp);

        ycomm.registerCallback((byte) commandValue, new CallbackView(getApplicationContext(), inp) {
            @Override
            public void run(byte type, byte command, byte[] data, byte data_langth) {
                // TODO Auto-generated method stub
                String str = new String(data);
                ((TextView) this.view).setText(str);
            }
        });
    } else {
        return;
    }
    view.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));

    row.addView(cmdView);
    row.addView(view);
    ((LinearLayout) findViewById(R.id.controls_layout)).addView(row);

}

From source file:com.albertcbraun.cms50fw.alert.MainUIFragment.java

private void setUpSeekBar(SharedPreferences defaultSettingsPreference, SeekBar seekBar,
        TextView correspondingTextView, Integer correspondingInteger,
        @SuppressWarnings("SameParameterValue") String maxValueSharedPrefsKeyName, int defaultMaxValue,
        String currentValueSharedPrefsKeyName, int defaultCurrValue) {

    SeekBar.OnSeekBarChangeListener seekBarChangeListener = new SeekBarChangeListener(getActivity(),
            correspondingTextView, correspondingInteger, currentValueSharedPrefsKeyName);

    seekBar.setMax(defaultSettingsPreference.getInt(maxValueSharedPrefsKeyName, defaultMaxValue));
    int currValue = defaultSettingsPreference.getInt(currentValueSharedPrefsKeyName, defaultCurrValue);
    correspondingTextView.setText(String.valueOf(currValue));
    seekBar.setProgress(currValue);//from  w ww . j  a  v  a2s.co  m
    seekBar.setOnSeekBarChangeListener(seekBarChangeListener);
}

From source file:com.azita.iot.ioclient.activity.MainActivity.java

public void ShowDimmerSeekBarDialog() {
    final AlertDialog.Builder popDialog = new AlertDialog.Builder(this, R.style.SeekbarAlertDialogStyle); //getSupportActionBar().getThemedContext()); //this);
    final LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
    final View Viewlayout = inflater.inflate(R.layout.activity_dimmer,
            (ViewGroup) findViewById(R.id.layout_Dimmerdialog));
    final TextView dimmertxtItem = (TextView) Viewlayout.findViewById(R.id.dimmertxtItem);

    SeekBar DimmerSeekBar = (SeekBar) Viewlayout.findViewById(R.id.DimmerSeekBar);

    DimmerSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            dimmertxtItem.setText("Value of : " + progress);
        }// ww w .j a  v  a  2  s . c  o  m

        public void onStartTrackingTouch(SeekBar arg0) {

        }

        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });

    popDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    popDialog.create();
    popDialog.show();
}