Hbutton.setOnClickListener(
new Button.OnLongClickListener(){
public boolean onLongClick(View v){
TextView Htext = (TextView) findViewById(R.id.Htext);
Htext.setText("Hunny");
return true;
}
}
);这段代码有什么问题??它会给出一个错误
(anonymous android.view.View.OnLongClickListener)发布于 2016-07-26 21:26:16
您必须设置onLongClickListener:
Hbutton.setOnLongClickListener(
new Button.OnLongClickListener(){
public boolean onLongClick(View v){
TextView Htext = (TextView) findViewById(R.id.Htext);
Htext.setText("Hunny");
return true;
}
}
);发布于 2016-07-26 21:30:04
试试这种方式,
Button Hbutton = (Button) findViewById(R.id.YOUR_BUTTON_ID);
Hbutton.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// TODO Auto-generated method stub
//do your stuff here
return true;
}
});https://stackoverflow.com/questions/38591129
复制相似问题