在同一个activity中需要用到这个两个监听事件 可是同时导入 会冲突 解决办法是 调用时都带上全路径名。如
new android.content.DialogInterface.OnClickListener()
关于android 双击事件
private intcount;//计算点击的次数
private longfirstClick;//第一次点击的时间 long型
private longlastClick;//最后一次点击的时间
private intfirstId;//第一次点击的button的id
mSurfaceView.setOnTouchListener(newOnTouchListener(){
@Override
publicboolean onTouch(View v, MotionEvent event) {
//TODO Auto-generated method stub
if(event.getAction()==MotionEvent.ACTION_DOWN){
//如果第二次点击 距离第一次点击时间过长那么将第二次点击看为第一次点击
if(firstClick!=0 && firstId!=0&&System.currentTimeMillis()-firstClick>300){
count = 0;
firstId = 0;
}
count++;
if(count==1){
firstClick = System.currentTimeMillis();
//记录第一次点得按钮的id
firstId = v.getId();
}else if(count==2){
lastClick = System.currentTimeMillis();
//两次点击小于300ms 也就是连续点击
if(lastClick-firstClick<200){
//第二次点击的button的id
int id = v.getId();
//判断两次点击的button是否是同一个button
if(id == firstId){
switch(id){
case R.id.surface:
TabHost tabs = getTabHost();
if(surfaceViewState == SURFACEVIEW_STATE_PREVIEW) {
surfaceViewState= SURFACEVIEW_STATE_PLAYING;
tabs.setVisibility(View.GONE);
topLayout.setVisibility(View.GONE);
if(playerActivity != null
&&playerActivity.getPlayerHolder() != null) {
//playerActivity.getPlayerHolder().setFixedSize(800, 480);
LayoutParamslp = mSurfaceView.getLayoutParams();
lp.width= 1024;
lp.height= 480;
mSurfaceView.setLayoutParams(lp);
isFullscreen=true;
}
}else if (surfaceViewState == SURFACEVIEW_STATE_PLAYING) {
surfaceViewState= SURFACEVIEW_STATE_PREVIEW;
tabs.setVisibility(View.VISIBLE);
topLayout.setVisibility(View.VISIBLE);
main_bottomleft.setVisibility(View.VISIBLE);
isFullscreen=false;
}
break;
}
}
}
}
}
returnfalse;
}} );