ポップアップのレイアウトが次のようなアプリでカスタム ポップアップを作成しました。
<?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>
「トラック」(LinearLayout) に webview を追加します。コードで、このレイアウトのボタンに OnClick イベント リスナーを追加しますが、動作しません。Log.i("clicked",".... "); onclickが起動するかどうかを確認するが、起動しない
追加情報:
ポップアップウィンドウには次のものがあります:
mWindow.setTouchable(true);
mWindow.setFocusable(true);
mWindow.setOutsideTouchable(true);
mWindow.setContentView(mRootView); // mRootView is the inflated layout above.
ポップアップの完全なコードは次のとおりです。
拡張クラスは次のとおりです。
注意: これは「QuickAction ダイアログ」の修正版です。
これが私のポップアップの外観です(同じレイアウトにする別の方法がある場合)、その小さな円形のボタンをクリックできるのは素晴らしいことです)
更新: コードに問題が見つかりました:
View rootView = mInflater.inflate(R.layout.popup_fullscreen,null);
final Button b = (Button) rootView.findViewById(R.id.popup_closer
新しいビューを膨張させるのではなく、膨張したビューの同じインスタンスを使用する必要がありました。
つまり、正しいコードは次のとおりです。
// Changed the View rootView .....etc to mRootView;
final Button b = (Button) mRootView.findViewById(R.id.popup_closer
ここで別の問題があります。ボタンを 2 回タッチして機能させる必要があります。最初のタッチ イベントがポップアップまたは WebView によって消費され、2 回目が機能するようです。