当用户使用鼠标单击时,通常会在桌面上生成单击事件。但是您不会将鼠标与智能手机一起使用。
到目前为止,我还没有找到在我的触摸屏上生成点击事件的方法。是否有某些硬件功能,您可以“点击”它们?
当用户使用鼠标单击时,通常会在桌面上生成单击事件。但是您不会将鼠标与智能手机一起使用。
到目前为止,我还没有找到在我的触摸屏上生成点击事件的方法。是否有某些硬件功能,您可以“点击”它们?
首先,当 Android 手机上的用户点击“桌面”(主屏幕)时,您无法获得 UI 点击事件。只有当用户点击您应用中的某些内容时,您才会收到点击事件。
取自处理 UI 事件教程:
// Create an anonymous implementation of OnClickListener
private OnClickListener mCorkyListener = new OnClickListener() {
public void onClick(View v) {
// do something when the button is clicked
}
};
protected void onCreate(Bundle savedValues) {
...
// Capture our button from layout
Button button = (Button)findViewById(R.id.corky);
// Register the onClick listener with the implementation above
button.setOnClickListener(mCorkyListener);
...
}