我自定义Android默认搜索栏以垂直方式显示并使用片段获取用户的一些反馈。
首次发布后,它显示正常。但是,一旦我提交了我的第一反馈,我就会使用包含我自定义的Vertical Seek Bar的片段重新启动活动。
那时,Vertical Seekbar中的拇指将变为“0”,但进度不会变为“0”并显示一些进展。 :(
下面我正在添加我的垂直搜索条形码,如果我错过任何东西请建议我。
public class VerticalSeekBar extends SeekBar {
private int mLastProgress = 0;
private OnSeekBarChangeListener mOnChangeListener;
public VerticalSeekBar(Context context) {
super(context);
}
public VerticalSeekBar(Context context, AttributeSet attrs) {
super(context, attrs);
}
public synchronized int getMaximum() {
return getMax();
}
@Override
protected void onDraw(Canvas c) {
c.rotate(-90);
c.translate(-getHeight(), 0);
super.onDraw(c);
}
@Override
protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(heightMeasureSpec, widthMeasureSpec);
setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(h, w, oldh, oldw);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!isEnabled()) {
return false;
}
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
if (mOnChangeListener != null) {
mOnChangeListener.onStartTrackingTouch(this);
}
setPressed(true);
setSelected(true);
break;
case MotionEvent.ACTION_MOVE:
super.onTouchEvent(event);
int progress = getMax() - (int) (getMax() * event.getY() / getHeight());
// Ensure progress stays within boundaries
if (progress < 0) {
progress = 0;
}
if (progress > getMax()) {
progress = getMax();
}
setProgress(progress); // Draw progress
if (progress != mLastProgress) {
// Only enact listener if the progress has actually changed
mLastProgress = progress;
if (mOnChangeListener != null) {
mOnChangeListener.onProgressChanged(this, progress, true);
}
}
onSizeChanged(getWidth(), getHeight(), 0, 0);
setPressed(true);
setSelected(true);
break;
case MotionEvent.ACTION_UP:
if (mOnChangeListener != null) {
mOnChangeListener.onStopTrackingTouch(this);
}
setPressed(false);
setSelected(false);
break;
case MotionEvent.ACTION_CANCEL:
super.onTouchEvent(event);
setPressed(false);
setSelected(false);
break;
}
return true;
}
public synchronized void setMaximum(int maximum) {
setMax(maximum);
}
@Override
public void setOnSeekBarChangeListener(OnSeekBarChangeListener onChangeListener) {
this.mOnChangeListener = onChangeListener;
}
public synchronized void setProgressAndThumb(int progress) {
setProgress(progress);
onSizeChanged(getWidth(), getHeight(), 0, 0);
if (progress != mLastProgress) {
mLastProgress = progress;
if (mOnChangeListener != null) {
mOnChangeListener.onProgressChanged(this, progress, true);
}
}
}
public synchronized void setMyProgress(int progress) {
setProgress(progress);
}
}
答案 0 :(得分:0)
最后我得到了解决问题的方法。 在创建垂直seekBar的.xml中我使用了 android:progressDrawable =“@ drawable / seek”但是在seek.xml中我忘了将标题声明为
1) Clear a cookie value
2) Set 307 header value and
3) Adding Location header with redirect url (say request B) value.
item android:id =“@ android:id / progress”。