2012-01-05 101 views
4


我想與包含Facebook登錄站點的webview進行對話。
我試着用PopupWindow - 點擊文本框後沒有顯示鍵盤。
與AlertDialog相同。最後,我使用了純粹的Dialog類,它是「工作」的,但是當我點擊文本字段時,整個webview閃爍並變爲除textfield之外的透明對象。
我在文本框焦點後附加了警報框和Facebook登錄網站的屏幕截圖。

我嘗試設置硬件加速或不同的背景,但沒有任何影響。 有沒有其他的方式來顯示在webview中的Facebook登錄彈出窗口?

感謝您的幫助! 代碼:Webview與對話框中的Facebook登錄閃爍

Dialog dialog = new Dialog(MyActivity.this); 
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
        dialog.setContentView(R.layout.webview_popup); 
        dialog.setCanceledOnTouchOutside(true); 


        dialog.setCancelable(true); 
        WebView popupWebview = (WebView)dialog.findViewById(R.id.webViewFromPopup); 

        popupWebview.loadUrl(url); 

        dialog.show(); 

XML:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:id="@+id/popupWindow" 
    android:background="#000" 
    android:minHeight="600dp"> 

    <WebView 
     android:id="@+id/webViewFromPopup" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layerType="software" 
     android:layout_weight="0.8" 
     android:background="#FFFFFFFF" 
     /> 

</LinearLayout> 

enter image description here SOLUTION:


我建立程序對話框 - 這是解決問題......不知何故。
代碼:

/* webview popup */ 
    private Dialog webViewPopup;    

private void showWebViewPopup(final String url) 
{ 
    Dialog dialog = new Dialog(MyActivity.this); 
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
    dialog.setContentView(R.layout.webview_popup); 

    dialog.setCancelable(true); 
    WebView popupWebview = new WebView(MyActivity.this); 
    LayoutParams params = new LinearLayout.LayoutParams(
     LayoutParams.MATCH_PARENT, 
     LayoutParams.WRAP_CONTENT, 0.99f); 
    popupWebview.setLayoutParams(params); 

    Button cancelButton = new Button(MyActivity.this); 
    LayoutParams bParams = new LinearLayout.LayoutParams(
     LayoutParams.MATCH_PARENT, 
     LayoutParams.WRAP_CONTENT, 0.01f); 
    cancelButton.setLayoutParams(bParams); 
    cancelButton.setText("Cancel"); 
    cancelButton.setOnClickListener(new OnClickListener() { 

      public void onClick(View v) { 
       webViewPopup.dismiss(); 
      } 
     }); 

    LinearLayout popupLayout = (LinearLayout) dialog.findViewById(R.id.popupWindow); 
    popupLayout.addView(popupWebview); 
    popupLayout.addView(cancelButton); 
    dialog.show(); 

    popupWebview.loadUrl(url); 
    webViewPopup = dialog; 
} 

XML:(webview_popup.xml文件)

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:id="@+id/popupWindow" 
    android:minHeight="600dp" 
    > 

</LinearLayout> 

回答

0

由於字段輸入給你的麻煩,一個解決辦法是捕捉到的數據在你自己的形式並在到達webview時進行處理。

設置它以便用戶在webview中選擇字段時編輯文本視圖和鍵盤彈出。

+0

捕獲Facebook密碼...?男人,這不是最好的主意 - 我怎麼會把它發送到Facebook網站。不提這不合法我想 – Piotr 2012-01-05 19:22:04