2011-02-25 60 views
0

當用戶使用鼠標單擊時,通常會生成桌面上的單擊事件。但是你不使用智能手機的鼠標。哪個用戶操作導致單擊事件

到目前爲止,我沒有找到方法在我的觸摸屏上生成單擊事件。是否有某些硬件功能,你可以「點擊」?

回答

1

首先,當用戶在Android手機上點擊「桌面」(主屏幕)時,您無法獲取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); 
    ... 
} 

Handling UI Events採取教程

相關問題