防止重复点击按钮方案总结

来源:互联网 发布:淘宝美工需要掌握什么 编辑:程序博客网 时间:2024/06/14 19:03


第一种

按钮按下之后,将按钮置成不可点击,一段时间后设置回来。

代码如下

  1. public static void disabledView(final View v) {  
  2.         v.setClickable(false);  
  3.         new Handler().postDelayed(new Runnable() {  
  4.   
  5.             @Override  
  6.             public void run() {  
  7.                 v.setClickable(true);  
  8.             }  
  9.         }, 1000);  

  10.     }  

这种方法简单 但是 个人感觉并不是很好,一个不可点击的按钮给用户的心里就是添堵的。

第二种

允许用户点击,但是不响应频繁的点击。

代码:

long lastClick ;
public void onClick(View v) {
   if (System.currentTimeMillis() - lastClick <= 1000){
          return;      }
      lastClick = System.currentTimeMillis();
 }
这种方法记录了一个上次响应的时间戳,对比一下当前的时间如果小于设置的时间间隔那么就不响应。
这种方法看起来很美,但是一般Button的监听器都是如下的
代码:
    lastClick = System.currentTimeMillis();  <span style="white-space:pre"></span>(v.getId()){            R.id.bth1: xxx  ;               <span style="white-space:pre"></span>break;           R.id.btn2: xxx;        }    }
</pre><span style="font-family:Consolas,Bitstream Vera Sans Mono,Courier New,Courier,monospace"><br /></span><span style="font-family:Consolas,Bitstream Vera Sans Mono,Courier New,Courier,monospace">假如你是像上面代码一般几个BUtton共用一个监听器,就会出现点击 btn1后 在时间间隔内 bth2 是不能响应的。</span></div><div class="line number1 index0 alt2" style="list-style:none; line-height:15.390625px; font-size:14px; color:rgb(51,51,51); border:0px!important; padding:0px 1em!important; margin:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"><br /></div><div class="line number1 index0 alt2" style="list-style:none; line-height:15.390625px; font-size:14px; color:rgb(51,51,51); border:0px!important; padding:0px 1em!important; margin:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"><span style="font-family:Consolas,Bitstream Vera Sans Mono,Courier New,Courier,monospace">记录每一个按钮的时间戳可以解决。</span></div><h1><span style="font-family:Consolas,Bitstream Vera Sans Mono,Courier New,Courier,monospace">第三种</span></h1><div class="line number1 index0 alt2" style="list-style:none; line-height:15.390625px; font-size:14px; color:rgb(51,51,51); border:0px!important; padding:0px 1em!important; margin:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"><span style="font-family:Consolas,Bitstream Vera Sans Mono,Courier New,Courier,monospace"><span style="white-space:pre"></span>其实第一种 也好 第二种也罢。都是一个套路,先响应一个点击事件,然后在时间间隔内就不再响应其他的点击。</span></div><div class="line number1 index0 alt2" style="list-style:none; line-height:15.390625px; font-size:14px; color:rgb(51,51,51); border:0px!important; padding:0px 1em!important; margin:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"><span style="font-family:Consolas,Bitstream Vera Sans Mono,Courier New,Courier,monospace"><span style="white-space:pre"></span>换一个思路就是 我们给 要响应的事件加上一个定时器,在一定的时间后执行。如果在这段时间内有按钮按下 则取消上次的定时器。将这次要响应的时间上定时器。</span></div><div class="line number1 index0 alt2" style="list-style:none; line-height:15.390625px; font-size:14px; color:rgb(51,51,51); border:0px!important; padding:0px 1em!important; margin:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"><span style="font-family:Consolas,Bitstream Vera Sans Mono,Courier New,Courier,monospace"><span style="white-space:pre"></span>这样做的好处是代码总是会响应最后按下的按钮。</span></div><div class="line number1 index0 alt2" style="list-style:none; line-height:15.390625px; font-size:14px; color:rgb(51,51,51); border:0px!important; padding:0px 1em!important; margin:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"><span style="font-family:Consolas,Bitstream Vera Sans Mono,Courier New,Courier,monospace">代码 如下:</span></div><div class="line number1 index0 alt2" style="list-style:none; line-height:15.390625px; font-size:14px; color:rgb(51,51,51); border:0px!important; padding:0px 1em!important; margin:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"><span style="font-family:Consolas,Bitstream Vera Sans Mono,Courier New,Courier,monospace"><br /></span></div><div class="line number1 index0 alt2" style="list-style:none; line-height:15.390625px; font-size:14px; color:rgb(51,51,51); border:0px!important; padding:0px 1em!important; margin:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"><span style="font-family:Consolas,Bitstream Vera Sans Mono,Courier New,Courier,monospace"></span><table border="0" cellpadding="0" cellspacing="0" style="list-style:none; width:613px; font-size:14px; color:rgb(51,51,51); border:0px!important; padding:0px!important; margin:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; min-height:inherit!important"><tbody style="border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important"><tr style="list-style:none; border:0px!important; padding:0px!important; margin:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important"><td class="gutter" style="list-style:none; border:0px!important; padding:0px!important; margin:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; font-size:1em!important; min-height:inherit!important; color:rgb(175,175,175)!important"><div class="line number1 index0 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">1</div><div class="line number2 index1 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">2</div><div class="line number3 index2 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">3</div><div class="line number4 index3 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">4</div><div class="line number5 index4 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">5</div><div class="line number6 index5 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">6</div><div class="line number7 index6 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">7</div><div class="line number8 index7 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">8</div><div class="line number9 index8 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">9</div><div class="line number10 index9 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">10</div><div class="line number11 index10 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">11</div><div class="line number12 index11 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">12</div><div class="line number13 index12 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">13</div><div class="line number14 index13 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">14</div><div class="line number15 index14 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">15</div><div class="line number16 index15 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">16</div><div class="line number17 index16 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">17</div><div class="line number18 index17 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">18</div><div class="line number19 index18 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">19</div><div class="line number20 index19 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">20</div><div class="line number21 index20 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">21</div><div class="line number22 index21 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">22</div><div class="line number23 index22 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">23</div><div class="line number24 index23 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">24</div><div class="line number25 index24 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">25</div><div class="line number26 index25 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">26</div><div class="line number27 index26 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">27</div><div class="line number28 index27 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">28</div><div class="line number29 index28 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">29</div><div class="line number30 index29 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">30</div><div class="line number31 index30 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">31</div><div class="line number32 index31 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">32</div><div class="line number33 index32 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">33</div><div class="line number34 index33 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">34</div><div class="line number35 index34 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">35</div><div class="line number36 index35 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">36</div><div class="line number37 index36 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">37</div><div class="line number38 index37 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">38</div><div class="line number39 index38 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">39</div><div class="line number40 index39 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">40</div><div class="line number41 index40 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">41</div><div class="line number42 index41 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">42</div><div class="line number43 index42 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">43</div><div class="line number44 index43 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">44</div><div class="line number45 index44 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">45</div><div class="line number46 index45 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">46</div><div class="line number47 index46 alt2" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">47</div><div class="line number48 index47 alt1" style="list-style:none; border-width:0px 3px 0px 0px!important; padding:0px 0.5em 0px 1em!important; margin:0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; white-space:pre!important">48</div></td><td class="code" style="list-style:none; width:573px; border:0px!important; padding:0px!important; margin:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; font-size:1em!important; min-height:inherit!important"><pre style="background-color: rgb(255, 255, 255); font-family: 宋体; font-size: 9pt;">@Override<span style="color:#000080;"><strong>public boolean </strong></span>onTouchEvent(MotionEvent event) {    <span style="color:#000080;"><strong>return super</strong></span>.onTouchEvent(event);}
//new 一个handler,用于消息处理
 
 Handler handler = newHandler(){
       @Override
       publicvoidhandleMessage(Message msg) {
           super.handleMessage(msg);
           if(msg.what == GOTO_DIALOG){
               //调用button点击事件处理方法goToDialog
               goToDialog((Integer)msg.obj);
           }
       }
   };
 
@Override
   publicvoidonClick(View v) {
 
      //发送handler消息之前,清空该消息
       handler.removeMessages(GOTO_DIALOG);
 
      //绑定一个msg,内容为接下来需要的button的ID,
       Message msg = Message.obtain();
       msg.what = GOTO_DIALOG;
       msg.obj = v.getId();
 
       //发送消息间隔1秒
       handler.sendMessageDelayed(msg,1000);
 
   }
 
   privatevoidgoToDialog(intid){
 
       //多个botton
 
          switch(id){
 
           caseR.id.btn_back:
 
           ......
 
           break;
 
          caseR.id.btn_sumbit:
 
           ......
 
           break;
 
     }


0 0