这是我的搜索条形码。这里只显示小时。我需要添加分钟。在搜索栏本身它显示AM和PM ..它没有显示分钟,如10分钟,20分钟。 .. ..出现在数据库中,如上午11点,下午4点..我还需要添加分钟...是否有可能在搜索栏...请帮我找出代码......
seekBar_startTime.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onProgressChanged(SeekBar seekBar, int progressValue, boolean fromUser) {
double progress;
String am_pm;
if (progressValue > 12)
{
progress = progressValue - 12;
am_pm = "PM";
}
else
{
progress = progressValue;
am_pm = "AM";
}
start_Time = String.valueOf(progress+am_pm);
textView_startTime.setText("Event Start Time :" + start_Time);
}
});
seekBar_endTime.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onProgressChanged(SeekBar seekBar, int progressValue,boolean fromUser) {
double progress;
String am_pm;
if (progressValue > 12)
{
progress = progressValue - 12;
am_pm = "PM";
}
else
{
progress = progressValue;
am_pm = "AM";
}
end_Time = String.valueOf(progress+am_pm);
textView_endTime.setText("Event Start Time :" + end_Time);
}
});
答案 0 :(得分:0)
我向搜索栏添加了更多步骤,因此您可以显示每小时:分钟配置。这可能是太多的步骤。如果是这种情况,请将其更改为5分钟步骤。如果你想改变它,请转到我的代码中的第4行,并将Progress设置为所需的分钟数,每个步骤应该有。
Seekbar seekbar_startTime = (Seekbar) findViewById(your seekbar id);
seekbar_startTime.setProgress(0);
seekbar_startTime.setMax(1440); //minutes in 24 hours
seekbar_startTime.setProgress(1);//set Stepsize = 1
seekBar_startTime.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onProgressChanged(SeekBar seekBar, int progressValue, boolean fromUser) {
int minutes;
int hours;
minutes = progressValue % 60;
int hours = progressValue/60;
String am_pm;
if (hours> 12)
{
hours= hours- 12;
am_pm = "PM";
}
else
{
am_pm = "AM";
}
String start_Time = ""+hours+":"+minutes+am_pm;
textView_startTime.setText("Event Start Time :" + start_Time);
}
});
seekBar_endTime.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onProgressChanged(SeekBar seekBar, int progressValue,boolean fromUser) {
int minutes;
int hours;
minutes = progressValue % 60;
int hours = progressValue/60;
String am_pm;
if (hours> 12)
{
hours= hours- 12;
am_pm = "PM";
}
else
{
am_pm = "AM";
}
String end_Time = ""+hours+":"+minutes+am_pm;
textView_endTime.setText("Event Start Time :" + end_Time);
}
});
如果您的代码中有任何复制粘贴错误,我很抱歉:)将这一点放在一起非常快。