Alex Rivera | Logout

how to fire an event when someone clicks anywhere on the screen in an android app?

Asked 2012-04-12T15:01:06.223
36

how can I catch the event when click occurs somewhere on the app screen? It doesn't matter if there is a button or something else. I just need to apply an onClick() event listener on the whole application screen.
How to do this?

Edit
Report

1 Answer

1

Give your main layout an id, then

LinearLayout root = (LinearLayout) findViewById(R.id.main_layout);
root.setOnClickListener(new OnClickListener() {
    public void onClick()
    {

    }
});
answered 2012-04-12T15:04:44.770

Your Answer