我听说在Android中,我们可以通过长按按钮来创建按钮的点击事件。
我想在我的应用程序中使用这个功能。
请问有人可以告诉我如何实现吗?
谢谢, 大卫
看一下 View.OnLongClickListener
。
public class MyActivity extends Activity {
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.content_layout_id);
final Button button = (Button) findViewById(R.id.button_id);
button.setOnLongClickListener(new View.OnLongClickListener() {
public boolean onLongClick(View v) {
// Perform action on click
return true;
}
});
}
}