Android请求专注于搜索栏

时间:2014-03-22 02:07:08

标签: android seekbar ontouchevent ontouchlistener

我要做的是从ontouch事件中可见的隐形搜索栏获得焦点。让我用一些代码更好地解释一下:

findViewById(R.id.myview).setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                switch (event.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                        mSeekBar.setVisibility(View.VISIBLE);
                        //now it becomes visible and i need to start moving the seekbar (left or right) while keeping touch                  
                        break;
                    case MotionEvent.ACTION_MOVE:
                        break;
                    case MotionEvent.ACTION_UP:
                        mSeekBar.setVisibility(View.GONE);
                        //once touch released hide the seekbar and stop tracking
                        break;  
                }
                return true;
            }
        });

1 个答案:

答案 0 :(得分:0)

你为什么要这样做?您的代码会在用户按下时显示SeekBar,只有在用户抬起手指时才会使其不可见。除非你进行多点触控处理,否则没有机会与SeekBar实际交互。