代码抛出编译时错误:
GnuTLS
代码:
Class 'Anonymous class derived from OnLongClickLister' is not abstract and does not override abstract method onLongClick(View) in OnLongClickListener
答案 0 :(得分:0)
你没有覆盖正确的方法。它是onLongClick
,而不是OnLongClick
。见下文:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button amitsbutton = (Button) findViewById(R.id.amitsbutton);
amitsbutton.setOnClickListener(
new Button.OnClickListener() {
public void onClick(View v) {
TextView amitstext = (TextView) findViewById(R.id.amitstext);
amitstext.setText("Small click is working");
}
}
);
amitsbutton.setOnLongClickListener(
new Button.OnLongClickListener() {
public boolean onLongClick(View v) {
TextView amitstext = (TextView) findViewById(R.id.amitstext);
amitstext.setText("long click is also working ");
return true;
}
}
);