Android的软键盘不开webView` [英] Android soft Keyboard not open in webView`

查看:199
本文介绍了Android的软键盘不开webView`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我M在AlertDialog使用的WebView来验证用户对Twitter的。 但是当我在web视图点击领域,Android键盘犯规开放。 这里是我的code,显示我如何加入的WebView在警告对话框。 我隐式调用Android键盘,但它打开键盘警告对话框后面。

这是我的code。

 公共静态无效webViewDialog(最后弦乐authorizationURL,最后整型)
{

    最终布尔correctPin;
    的System.out.println(以webViewDialog);
    集装箱=新的LinearLayout(上下文);
    container.setOrientation(LinearLayout.VERTICAL);

    container.setMinimumWidth(200);
    container.setMinimumHeight(320);

    web视图=新的WebView(上下文);
    webView.setMinimumWidth(200);
    webView.requestFocusFromTouch();
    webView.setMinimumHeight(380);
    webView.getSettings()setJavaScriptEnabled(真)。
    webView.setWebViewClient(新TwitterWebViewClient());
    webView.loadUrl(authorizationURL);
    webView.setBackgroundColor(0xFFbbd7e9);
    container.addView(web视图);

    构建webDialog =新AlertDialog.Builder(上下文);

    webDialog.setView(集装箱).setTitle(微博登录)
            .setPositiveButton(OK,新DialogInterface.OnClickListener()
        {

                @覆盖
                公共无效的onClick(DialogInterface对话,诠释其)
                {

                    如果(类型== 0)
                    {
                          twitterPin codeDialog的();
                        dialog.dismiss();

                    }
                }
        })。显示();
    showVirtualKeyboard();

}
公共静态无效showVirtualKeyboard()
{
    定时器定时=新的Timer();
    timer.schedule(新的TimerTask()
    {

         @覆盖
         公共无效的run()
         {
              InputMethodManager M =(InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);

              如果(M!= NULL)
              {
                // m.toggleSoftInput(0,InputMethodManager.HIDE_NOT_ALWAYS);
                m.toggleSoftInput(0,InputMethodManager.SHOW_IMPLICIT);
              }
         }

    },100);
}
 

解决方案

我使用的是PopupWindow里面坐了一个web视图,并经历了同样的问题,但如果我在父设置可聚焦到真正的问题解决了:

  popupWindow.setFocusable(真正的);
 

希望这有助于!

I m Using WebView in AlertDialog to authenticate user to twitter. but When i click on field in webview ,android keyboard doesnt open. here is my code that shows how i added webview in alert dialog. i implicitly call android keyboard but it open keyboard behind alert dialog.

here is my code.

public static void webViewDialog(final String authorizationURL, final int type)
{

    final boolean correctPin;
    System.out.println("In webViewDialog");
    container = new LinearLayout(context);
    container.setOrientation(LinearLayout.VERTICAL);

    container.setMinimumWidth(200);
    container.setMinimumHeight(320); 

    webView = new WebView(context);
    webView.setMinimumWidth(200);
    webView.requestFocusFromTouch();
    webView.setMinimumHeight(380);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebViewClient(new TwitterWebViewClient());
    webView.loadUrl(authorizationURL);
    webView.setBackgroundColor(0xFFbbd7e9);
    container.addView(webView);

    Builder webDialog = new AlertDialog.Builder(context);

    webDialog.setView(container).setTitle("Twitter Login")
            .setPositiveButton("Ok", new DialogInterface.OnClickListener()
        {

                @Override
                public void onClick(DialogInterface dialog, int which) 
                {

                    if (type == 0) 
                    {
                          twitterPinCodeDialog();
                        dialog.dismiss();

                    }
                }
        }).show();
    showVirtualKeyboard();

}
public static void showVirtualKeyboard()
{
    Timer timer = new Timer();
    timer.schedule(new TimerTask()
    {

         @Override
         public void run()
         {
              InputMethodManager m = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);

              if(m != null)
              {
                // m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
                m.toggleSoftInput(0, InputMethodManager.SHOW_IMPLICIT);
              } 
         }

    }, 100);  
}

解决方案

I am using a PopupWindow with a WebView inside it and experienced the same problem, but if I set focusable to true in the parent the problem goes away:

popupWindow.setFocusable(true);

Hope this helps!

这篇关于Android的软键盘不开webView`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆