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?
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) { } });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With