how to fire an event when someone clicks anywhere on the screen in an android app?
android, events
Solution
`setonclicklistner` for main layout of your layout file....
Like....main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/mainlayout">
<!- Your other view->
</Relativelayout>
and set click listener for mainlayout...
RelativeLayout rlayout = (RelativeLayout) findViewById(R.id.mainlayout);
rlayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
Problem
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?