gpt4 book ai didi

android - 搜索栏没有到达终点

转载 作者:行者123 更新时间:2023-11-29 00:30:37 35 4
gpt4 key购买 nike

我正在开发一款使用 seekbar 的应用程序。我的 seekbar 的最大值为 6,即 android:max="6",因为我希望间隔为 5。我的问题是 seekbar 没有到达终点我尝试了很多东西但仍然无能为力,所以任何人都可以建议我该怎么做。我的代码是

 public class MainActivity  extends Activity implements SeekBar.OnSeekBarChangeListener 
{

SeekBar seekBar;


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

seekBar=(SeekBar)findViewById(R.id.seek);
int max = 6;
seekBar.setMax(max);
seekBar.setProgress(0);

seekBar.setOnSeekBarChangeListener(this);
}

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


}

public void onStartTrackingTouch(SeekBar seekBar) {
// Notify that the user has started a touch gesture.


}

public void onStopTrackingTouch(SeekBar seekBar) {
// Notify that the user has finished a touch gesture.

}

}

谢谢

最佳答案

xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
>

<SeekBar
android:layout_width="match_parent"
android:layout_height="30dp"
android:max="6"
android:id="@+id/sb"
/>
</LinearLayout>

Activity .java

public class MyActivity extends Activity implements SeekBar.OnSeekBarChangeListener {

private SeekBar sb;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
sb = (SeekBar)findViewById(R.id.sb);
sb.setOnSeekBarChangeListener(this);
}


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

}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {

}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {

}
}

enter image description here

所有的工作都很有魅力。希望对您有所帮助。

关于android - 搜索栏没有到达终点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16009877/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com