如何在vitamio中拖动搜索栏时实现即时搜索

时间:2013-03-26 08:38:30

标签: android drag seekbar

当我拖动搜索栏时,屏幕中显示的框架不会改变,直到我停止拖动。在Android库中的VideoView中,拖动搜索条时帧可以平滑变换。

1 个答案:

答案 0 :(得分:1)

实施SeekBar'onSeekBarChangeListener

e.g。

private OnSeekBarChangeListener mSeekListener = new OnSeekBarChangeListener() {
    public void onStartTrackingTouch(SeekBar bar) {
        mDragging = true;
        show(3600000);
        mHandler.removeMessages(SHOW_PROGRESS);
        if (mInstantSeeking)
            mAM.setStreamMute(AudioManager.STREAM_MUSIC, true);
        if (mInfoView != null) {
            mInfoView.setText("");
            mInfoView.setVisibility(View.VISIBLE);
        }
    }

    public void onProgressChanged(SeekBar bar, int progress, boolean fromuser) {
        if (!fromuser)
            return;

        long newposition = (mDuration * progress) / 1000;
        String time = StringUtils.generateTime(newposition);
        if (mInstantSeeking)
            mPlayer.seekTo(newposition);
        if (mInfoView != null)
            mInfoView.setText(time);
        if (mCurrentTime != null)
            mCurrentTime.setText(time);
    }

    public void onStopTrackingTouch(SeekBar bar) {
        if (!mInstantSeeking)
            mPlayer.seekTo((mDuration * bar.getProgress()) / 1000);
        if (mInfoView != null) {
            mInfoView.setText("");
            mInfoView.setVisibility(View.GONE);
        }
        show(sDefaultTimeout);
        mHandler.removeMessages(SHOW_PROGRESS);
        mAM.setStreamMute(AudioManager.STREAM_MUSIC, false);
        mDragging = false;
        mHandler.sendEmptyMessageDelayed(SHOW_PROGRESS, 1000);
    }
};