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

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

 2010-09-06 08:38:00 来源:WEB开发网   
核心提示:// TODO Auto-generated method stubdo {i++;try {Thread.sleep(400);Message msg = hand.obtainMessage();msg.arg1 = i;msg.sendToTarget();} catch (InterruptedExceptio

// TODO Auto-generated method stub

do {

i++;

try {

Thread.sleep(400);

Message msg = hand.obtainMessage();

msg.arg1 = i;

msg.sendToTarget();

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

} while (isStop);

}

};

}

/**

* 获取一个handler 对象

* @param 0代表onTouch 1代表onChange

* @param 视图对象

* @param 进度

* @return 返回一个handler对象

*/

public Handler getHandler(final int j, final View v, final int progress) {

Handler h = new Handler() {

@Override

public void handleMessage(Message msg) {

// TODO Auto-generated method stub

switch (j) {

case 0:

if (msg.arg1 == 3) {

if (longClick != null) {

longClick.onLongClick(v);

}

}

break;

case 1:

if (msg.arg1 == 1) {

pp = progress;

}

if (msg.arg1 == 2) {

if (pp != progress) {

i = 0;

}

}

if (msg.arg1 == 3) {

i = 0;

if (pp == progress) {

if (longClick != null) {

longClick.onLongClick(seekBarDemo.this);

}

}

}

break;

}

super.handleMessage(msg);

}

};

return h;

}

/**

* 设置长按事件

* @param longClick

*/

public void setOnLongSeekBarClick(onLong longClick) {

this.longClick = longClick;

}

/**

* 设置进度改变事件

* @param change

*/

public void setOnSeekBarChange(onChange change) {

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

Tags:Android SeekBar 支持

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