WEB开发网
开发学院手机开发Android 开发 Android 让你的SeekBar 也支持长按事件 阅读

Android 让你的SeekBar 也支持长按事件

 2010-09-06 08:38:00 来源:WEB开发网   
核心提示:public void onProgressChanged(seekBarDemo seekBar, int progress,boolean fromUser);}实现接口函数:this.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {@Overri

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

上一页  1 2 3 4 5 6  下一页

Tags:Android SeekBar 支持

编辑录入:coldstar [复制链接] [打 印]
赞助商链接