2012-01-05 98 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