Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Today, the test found that sending data, their
onLongClick事件返回为false时不执行(概率)onClick
Test a variety of approaches
Specially changed the test project
The following demo without any problems
package cn.edu.caztc.ceshi;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity implements View.OnClickListener,View.OnLongClickListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button)findViewById(R.id.button);
button.setOnLongClickListener(this);
button.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.d("测试", "onClick: ");
}
@Override
public boolean onLongClick(View v) {
// TODO Auto-generated method stub
Log.d("测试", "onLongClick: ");
return false;
}
}
there is only one button layout
However that does not work, the end result found
Yes, I opened the millet phone Press and enhancement tool, it will grab the last press event. . .
Solution: ah of course, is closed