I have made a custom popup in an app where the layout of the popup is as follows:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ScrollView
android:id="@+id/scroller"
android:layout_margin="4dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/popup3"
android:fadingEdgeLength="0dip"
android:scrollbars="none">
<LinearLayout
android:id="@+id/tracks"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:padding="8dip"/>
</ScrollView >
<Button
android:id="@+id/popup_closer"
android:layout_width="70dp"
android:layout_height="70dp"
android:clickable="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_below="@id/scroller"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="0dip"
android:layout_marginLeft="0dip"
android:background="@drawable/close_popup"
android:text=" X " />
</RelativeLayout>
In the "tracks"(LinearLayout) I add a webview, now in my code I add OnClick event listener on the button in this Layout, but it never works, I added a Log.i("clicked","...."); to check if the onclick fires but it doesn't
Additional info:
the popup window has the following :
mWindow.setTouchable(true);
mWindow.setFocusable(true);
mWindow.setOutsideTouchable(true);
mWindow.setContentView(mRootView); // mRootView is the inflated layout above.
The full code for the popup is here :
and the Extended class is here:
Notice: this is a modified version of "QuickAction dialog"
Here's how my popup looks like (If there's another way to have the same layout) and be able to click on that small circular button It'd be great)
UPDATE: I found the problem in my code it was here :
View rootView = mInflater.inflate(R.layout.popup_fullscreen,null);
final Button b = (Button) rootView.findViewById(R.id.popup_closer
I should've used the same instance of the inflated view instead of inflating new view;
i.e the correct code is:
// Changed the View rootView .....etc to mRootView;
final Button b = (Button) mRootView.findViewById(R.id.popup_closer
Now I have another problem: I have to touch the button 2 times to make it work it seems that the first touch event is consumed by the popup or WebView then the second time works.