2014-01-15 46 views

回答

0

您可以通过确保开关实现这一目标无法点击

android:clickable="false" 

,然后是通过触摸事件到交换机

 final Switch switch = 
        (Switch) rootView.findViewById(R.id.lock_switch); 
     if (switch != null) { 
      // This combined with android:clickable="false" 
      // makes this a slide only switch 
      switch.setOnTouchListener(new View.OnTouchListener() { 
       @Override 
       public boolean onTouch(View v, MotionEvent event) { 
        switch.onTouchEvent(event); 
        return true; 
       } 
      }); 
     } 
添加触摸监听器