Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 为什么软键盘不能在对话框片段中的web视图中工作?_Android_Android Layout_Android Fragments_Webview_Android Dialogfragment - Fatal编程技术网

Android 为什么软键盘不能在对话框片段中的web视图中工作?

Android 为什么软键盘不能在对话框片段中的web视图中工作?,android,android-layout,android-fragments,webview,android-dialogfragment,Android,Android Layout,Android Fragments,Webview,Android Dialogfragment,在我的一个活动中,有一个按钮,按下这个按钮会打开一个对话框片段,在这个对话框片段中会出现一个web视图。我使用此web视图获取在线商店的用户信息,但当表单加载到web视图上时,我想输入信息,但软键盘不会出现。 在另一个活动中显示web视图是正常的,一切正常,我可以输入数据 调用对话框片段的我的主要活动: public class MainActivity extends AppCompatActivity implements InformationDialog44.InformationDia

在我的一个活动中,有一个按钮,按下这个按钮会打开一个对话框片段,在这个对话框片段中会出现一个web视图。我使用此web视图获取在线商店的用户信息,但当表单加载到web视图上时,我想输入信息,但软键盘不会出现。 在另一个活动中显示web视图是正常的,一切正常,我可以输入数据

调用对话框片段的我的主要活动:

public class MainActivity extends AppCompatActivity implements InformationDialog44.InformationDialogInfo {

Activity activity;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    activity=this;


    Button button=(Button)findViewById(R.id.showButton);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            InformationDialog44 dialog=new InformationDialog44();
            dialog.show(getSupportFragmentManager(),"parvaz-tag");
        }
    });
}
}
这是主布局(content_main.xml):


是否有任何限制(可能是出于安全原因)不允许在对话框片段中使用web视图上的键盘?

似乎没有人有明确的答案。我无法用这种方法解决问题,但最简单的方法是将您的活动显示为已回答的对话框


但在我的例子中,我不得不将样式名称替换为:android:theme=“@android:style/theme.Dialog”

似乎没有人有一个直截了当的答案。我无法用这种方法解决问题,但最简单的方法是将您的活动显示为已回答的对话框

但在我的例子中,我不得不将样式名称替换为:android:theme=“@android:style/theme.Dialog”

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="ir.parvaz.uitests.MainActivity"
tools:showIn="@layout/activity_main">
<Button
    android:id="@+id/showButton"
    android:text="Show Dialog"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_margin="10dp"
android:padding="10dp"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
    android:text="Hello World!"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
<WebView
    android:id="@+id/myWebView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"></WebView>
</LinearLayout>
public class InformationDialog44  extends DialogFragment {
InformationDialog44 myself; 

InformationDialogInfo listener;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
    super.onCreateDialog(savedInstanceState);
    AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View view=inflater.inflate(R.layout.dialog2,null);
    builder.setView(view);
    WebView myWebView=(WebView)view.findViewById(R.id.myWebView);
    myWebView.getSettings().setJavaScriptEnabled(true);        
    myWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    myWebView.getSettings().setLoadWithOverviewMode(true);
    myWebView.getSettings().setUseWideViewPort(true);

    myWebView.setWebViewClient(new WebViewClient()
       {
           @Override
           public boolean shouldOverrideUrlLoading(WebView view, String url){
               view.loadUrl(url);
               return true;
           }
           @Override
           public void onPageFinished(WebView view, final String url) {
               Log.i("parvaz-uitests","URL is: "+url);

           }
       }
    );

    myWebView.setBackgroundColor(Color.BLUE);
    myself=this;
    myWebView.loadUrl("http://www.google.com");
    return builder.create();
}



@Override
public void onAttach(Activity activity)
{
    super.onAttach(activity);
    try
    {
        listener=(InformationDialogInfo)activity;
    }
    catch(ClassCastException e)
    {
        Log.e("parvaz-error","Implement InformationDialogInfo. ");
        dismiss();
    }
}
public interface InformationDialogInfo
{
    void onOKClick(InformationDialog44 informationDialog);
    void onCancelClick(InformationDialog44 informationDialog);
}
}