android.widget.SeekBar.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中android.widget.SeekBar.<init>()方法的一些代码示例,展示了SeekBar.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SeekBar.<init>()方法的具体详情如下:
包路径:android.widget.SeekBar
类名称:SeekBar
方法名:<init>

SeekBar.<init>介绍

暂无

代码示例

代码示例来源:origin: ankidroid/Anki-Android

@Override
protected View onCreateDialogView() {
  LinearLayout.LayoutParams params;
  LinearLayout layout = new LinearLayout(mContext);
  layout.setOrientation(LinearLayout.VERTICAL);
  layout.setPadding(6, 6, 6, 6);
  mValueText = new TextView(mContext);
  mValueText.setGravity(Gravity.CENTER_HORIZONTAL);
  mValueText.setTextSize(32);
  params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
      LinearLayout.LayoutParams.WRAP_CONTENT);
  layout.addView(mValueText, params);
  mSeekBar = new SeekBar(mContext);
  mSeekBar.setOnSeekBarChangeListener(this);
  layout.addView(mSeekBar, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
      LinearLayout.LayoutParams.WRAP_CONTENT));
  if (shouldPersist()) {
    mValue = getPersistedInt(mDefault);
  }
  mSeekBar.setMax((mMax - mMin) / mInterval);
  mSeekBar.setProgress((mValue - mMin) / mInterval);
  String t = String.valueOf(mValue);
  mValueText.setText(mSuffix == null ? t : t.concat(mSuffix));
  return layout;
}

代码示例来源:origin: robolectric/robolectric

@Before
public void setup() {
 seekBar = new SeekBar(ApplicationProvider.getApplicationContext());
 shadow = Shadows.shadowOf(seekBar);
 listener = new TestSeekBarChangedListener();
 transcript = new ArrayList<>();
 seekBar.setOnSeekBarChangeListener(listener);
}

代码示例来源:origin: stackoverflow.com

MediaPlayer mMediaPlayer = new MediaPlayer();
 final SeekBar mSeelBar = new SeekBar(this);
 final int duration = mMediaPlayer.getDuration();
 final int amoungToupdate = duration / 100;
 Timer mTimer = new Timer();
 mTimer.schedule(new TimerTask() {
   @Override
   public void run() {
     runOnUiThread(new Runnable() {
       @Override
       public void run() {
         if (!(amoungToupdate * mSeelBar.getProgress() >= duration)) {
           int p = mSeelBar.getProgress();
           p += 1;
           mSeelBar.setProgress(p);
         }
       }
     });
   };
 }, amoungToupdate);

代码示例来源:origin: google/android-ui-toolkit-demos

label.setText(name + formattedValue);
final SeekBar seek = new SeekBar(this);
params = new LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
params.weight = .5f;

代码示例来源:origin: stackoverflow.com

SeekBar seekBar = new SeekBar(this);
seekBar.setMax(15);

代码示例来源:origin: stackoverflow.com

SeekBar seekBar = new SeekBar(this);
   final SeekBar seekBar2 = new SeekBar(this);
   seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
     @Override
     public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
       if (progress >= 100) seekBar2.setProgress(progress); // do the same for the other seekbars.
     }
     @Override
     public void onStartTrackingTouch(SeekBar seekBar) {
     }
     @Override
     public void onStopTrackingTouch(SeekBar seekBar) {
     }
   });

代码示例来源:origin: stackoverflow.com

SeekBar seek=new SeekBar(this);
 seek.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) {
   // Here call your code when progress will changes
   }
  });

代码示例来源:origin: stackoverflow.com

SeekBar seekBar1 = new SeekBar(this);
SeekBar seekBar2 = new SeekBar(this);
SeekBar seekBar3 = new SeekBar(this);

seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
  @Override
  public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    if (progress > 100) seekBar2.setProgress(progress-100); // do the same for the other seekbars.
  }
});

seekBar2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
  @Override
  public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    if (progress > 100) seekBar3.setProgress(progress-100); // do the same for the other seekbars.
  }
});

代码示例来源:origin: grzegorznittner/chanu

private void initPreference(Context context, AttributeSet attrs) {
  setValuesFromXml(attrs);
  seekBar = new SeekBar(context, attrs);
  seekBar.setMax(maxValue - minValue);
  seekBar.setOnSeekBarChangeListener(this);
}

代码示例来源:origin: vocollapse/Blockinger

private void initPreference(Context context, AttributeSet attrs) {
  setValuesFromXml(attrs);
  mSeekBar = new SeekBar(context, attrs);
  mSeekBar.setMax(mMaxValue - mMinValue);
  mSeekBar.setOnSeekBarChangeListener(this);
}

代码示例来源:origin: klinker24/Android-Blur-Launcher

private void initPreference(Context context, AttributeSet attrs) {
  setValuesFromXml(attrs);
  mSeekBar = new SeekBar(context, attrs);
  mSeekBar.setMax(mMaxValue - mMinValue);
  mSeekBar.setOnSeekBarChangeListener(this);
}

代码示例来源:origin: stackoverflow.com

public void MyLayout() {
  LinearLayout layout = new LinearLayout(this);

  TextView tvStart = new TextView(this);
  SeekBar sbProgress = new SeekBar(this);
  TextView tvEnd = new TextView(this);

  tvStart.setText("0");
  tvEnd.setText("100");
  sbProgress.setMax(100);

  LinearLayout.LayoutParams startParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
  LinearLayout.LayoutParams sbParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT);
  sbParams.weight = 1;
  LinearLayout.LayoutParams endParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
  layout.addView(tvStart, tvParams);
  layout.addView(sbProgress, sbParams);
  layout.addView(tvEnd, endParams);

  setContentView(layout);
}

代码示例来源:origin: powerpoint45/Lucid-Browser

private void initPreference(Context context, AttributeSet attrs) {
  setValuesFromXml(attrs);
  mSeekBar = new SeekBar(context, attrs);
  mSeekBar.setMax(mMaxValue - mMinValue);
  mSeekBar.setOnSeekBarChangeListener(this);
  
  setWidgetLayoutResource(R.layout.seek_bar_preference);
}

代码示例来源:origin: AEFeinstein/mtg-familiar

private void initPreference(Context context, AttributeSet attrs) {
  setValuesFromXml(attrs);
  mSeekBar = new SeekBar(context, attrs);
  mSeekBar.setMax(mMaxValue - mMinValue);
  mSeekBar.setOnSeekBarChangeListener(this);
  setWidgetLayoutResource(R.layout.seek_bar_preference);
}

代码示例来源:origin: tgwizard/sls

@Override
protected void onPrepareDialogBuilder(Builder builder) {
  // we "have" to create new views each time
  LinearLayout layout = new LinearLayout(mContext);
  layout.setLayoutParams(new LinearLayout.LayoutParams(
      LinearLayout.LayoutParams.FILL_PARENT,
      LinearLayout.LayoutParams.WRAP_CONTENT));
  // layout.setMinimumWidth(400);
  layout.setPadding(20, 20, 20, 20);
  mSeekBar = new SeekBar(mContext);
  mSeekBar.setLayoutParams(new ViewGroup.LayoutParams(
      ViewGroup.LayoutParams.FILL_PARENT,
      ViewGroup.LayoutParams.WRAP_CONTENT));
  mSeekBar.setMax(mStartMax);
  mSeekBar.setProgress(mStartProgress);
  layout.addView(mSeekBar);
  builder.setView(layout);
  super.onPrepareDialogBuilder(builder);
}

代码示例来源:origin: stackoverflow.com

public void ShowDialog(){
 final AlertDialog.Builder popDialog = new AlertDialog.Builder(this);
 final SeekBar seek = new SeekBar(this);
 seek.setMax(255);
 seek.setKeyProgressIncrement(1);

 popDialog.setIcon(android.R.drawable.btn_star_big_on);
popDialog.setTitle("Please Select Into Your Desired Brightness ");
 popDialog.setView(seek);

  seek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {


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

 txtView.setText("Value of : " + progress);
 }

代码示例来源:origin: stackoverflow.com

//This is the code you seek!

 public void ShowDialog(){
  final AlertDialog.Builder popDialog = new AlertDialog.Builder(this);
 final SeekBar seek = new SeekBar(this);
  seek.setMax(255);
 seek.setKeyProgressIncrement(1);

 popDialog.setIcon(android.R.drawable.btn_star_big_on);
popDialog.setTitle("Please Select Into Your Desired Brightness ");
popDialog.setView(seek);

 seek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {


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

 txtView.setText("Value of : " + progress);
 }

代码示例来源:origin: ogarcia/opensudoku

public SeekBarPreference(Context context, AttributeSet attrs) {
  super(context, attrs);
  setDialogLayoutResource(R.layout.preference_dialog_seek_bar);
  mSeekBar = new SeekBar(context, attrs);
  // Give it an ID so it can be saved/restored
  mSeekBar.setId(R.id.seek_bar);
  mSeekBar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
  TypedArray a =
      context.obtainStyledAttributes(attrs, R.styleable.SeekBarPreference);
  setMin(a.getInt(R.styleable.SeekBarPreference_min, mMin));
  setMax(a.getInt(R.styleable.SeekBarPreference_max, mMax));
  setValue(a.getInt(R.styleable.SeekBarPreference_value, mValue));
  setValueFormat(a.getString(R.styleable.SeekBarPreference_valueFormat));
  a.recycle();
}

代码示例来源:origin: leeowenowen/beauty-of-math

public SeekBarLayout(Context context) {
 super(context);
 mTitle = new TextView(context);
 mSeekbar = new SeekBar(context);
 addView(mTitle);
 addView(mSeekbar,
     new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, UIUtil.dp2px(context, 50)));
 UIUtil.setMargin(mTitle, 0, 0, UIUtil.dp2px(context, 5), 0);
}

代码示例来源:origin: stackoverflow.com

TableRow tr = new TableRow(this);
   tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
   /* Create a SeekBar to be the row-content. */
  SeekBar seekBar = new SeekBar(this);
     seekBar.setMax(15);
 //      seekBar.setIndeterminate(true);
     ShapeDrawable thumb = new ShapeDrawable(new OvalShape());
     thumb.setIntrinsicHeight(80);
     thumb.setIntrinsicWidth(30);
     seekBar.setThumb(thumb);
     seekBar.setProgress(1);
     seekBar.setVisibility(View.VISIBLE);
     seekBar.setBackgroundColor(Color.BLUE);
     LayoutParams lp = new LayoutParams(200, 50);
     seekBar.setLayoutParams(lp); 
 seekBar.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));

相关文章

SeekBar类方法