Android 让你的SeekBar 也支持长按事件
2010-09-06 08:38:00 来源:WEB开发网public void onProgressChanged(seekBarDemo seekBar, int progress,
boolean fromUser);
}
实现接口函数:
this.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
if (SeekBarChange != null) {
SeekBarChange.onStopTrackingTouch(seekBarDemo.this);
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
if (SeekBarChange != null) {
SeekBarChange.onStartTrackingTouch(seekBarDemo.this);
}
}
@Override
public void onProgressChanged(final SeekBar seekBar,
final int progress, boolean fromUser) {
if (SeekBarChange != null) {
SeekBarChange.onProgressChanged(seekBarDemo.this, progress,
fromUser);
}
hand = getHandler(1, seekBarDemo.this, progress);
}
});
完整的参考代码如下:
package org.lytsing.Android.qzoneloading;
import Android.content.Context;
import Android.os.Handler;
import Android.os.Message;
import Android.util.AttributeSet;
import Android.view.MotionEvent;
import Android.view.View;
import Android.view.View.OnTouchListener;
import Android.widget.SeekBar;
public class seekBarDemo extends SeekBar implements OnTouchListener {
private onLong longClick;
/**
* 长按接口
* @author terry
*
*/
public interface onLong {
public boolean onLongClick(View v);
}
private onChange SeekBarChange;
/**
* 进度改变接口
* @author terry
更多精彩
赞助商链接