Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.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 使用带有输入字符串值的webview_Android_Android Webview - Fatal编程技术网

Android 使用带有输入字符串值的webview

Android 使用带有输入字符串值的webview,android,android-webview,Android,Android Webview,我只是想问一下,我如何使用webview和edittext中输入的字符串? 例如,我创建了2个片段,其中一个显示webview,另一个从用户处获取2个edittext。我只想从2中输入edittext值。片段到1。碎片。因为我想创建如下URL:webView.loadUrl(“+ID+”&sifre=“+Password”) 这是我的第一个片段 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" x

我只是想问一下,我如何使用webview和edittext中输入的字符串? 例如,我创建了2个片段,其中一个显示webview,另一个从用户处获取2个edittext。我只想从2中输入edittext值。片段到1。碎片。因为我想创建如下URL:webView.loadUrl(“+ID+”&sifre=“+Password”)

这是我的第一个片段

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Tab1">

<WebView
    android:id="@+id/webView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

这是第二个

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Tab2">

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:paddingTop="80dp"
    android:paddingRight="30dp"
    android:paddingLeft="30dp"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Tab2">

    <ImageView
        android:src="@drawable/logo_small"
        android:id="@+id/logo"
        android:layout_marginBottom="30dp"
        android:layout_width="match_parent"
        android:layout_height="100dp" />
    <android.support.design.widget.TextInputLayout
        android:id="@+id/layout_id"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/logo">

        <EditText

            android:hint="ID"
            android:textColor="@color/colorPrimary"
            android:id="@+id/idx"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </android.support.design.widget.TextInputLayout>
    <android.support.design.widget.TextInputLayout
        android:id="@+id/layout_pass"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/layout_id"
        >

        <EditText
            android:inputType="textPassword"
            android:hint="Şifre"
            android:textColor="@color/colorPrimary"
            android:id="@+id/password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </android.support.design.widget.TextInputLayout>

    <Button
        android:id="@+id/btn_login"
        android:layout_below="@id/layout_pass"
        android:backgroundTint="@color/colorPrimaryDark"
        android:text="KAYDET"
        android:layout_marginTop="30dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
         />
</RelativeLayout>


您的问题太大,无法在此回答。而且它并不具体。我只想提一下这些步骤。如果搜索正确,您将找到特定部件的代码

  • 初始化
    EditText
    s。当用户单击登录按钮时,您将从编辑文本发送值

  • 在登录按钮上设置
    onClickListener
    。在侦听器内部,检查您的
    editText
    是否有值。如果它们有值,转到另一个片段

  • <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Tab1">
    
    <WebView
        android:id="@+id/webView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    
  • EditText
    的值发送到另一个片段,您可以通过多种方式执行此操作。一种是,只需将一个实例获取到目标片段对象,并发送值


    • 您的问题太大,无法在此回答。而且它并不具体。我只想提一下这些步骤。如果搜索正确,您将找到特定部件的代码

      • 初始化
        EditText
        s。当用户单击登录按钮时,您将从编辑文本发送值

      • 在登录按钮上设置
        onClickListener
        。在侦听器内部,检查您的
        editText
        是否有值。如果它们有值,转到另一个片段

      • <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".Tab1">
        
        <WebView
            android:id="@+id/webView1"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
        
      • EditText
        的值发送到另一个片段,您可以通过多种方式执行此操作。一种是,只需将一个实例获取到目标片段对象,并发送值


        • 我得到了这样的字符串,但在第一个片段中找不到使用的方法。你能给我看看吗

          public class Tab2 extends Fragment {
          
          
          public Tab2() {
              // Required empty public constructor
          }
          EditText ed1,ed2;
          private Button b1;
          
          @Nullable
          @Override
          public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                                   @Nullable Bundle savedInstanceState) {
              View view = inflater.inflate(R.layout.fragment_tab2, container, false);
          
              b1 = view.findViewById(R.id.btn_login);
              ed1 = view.findViewById(R.id.idx);
              ed2 = view.findViewById(R.id.password);
          
              b1.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                  String n = ed1.getText().toString();
                  String p = ed2.getText().toString();
          
                  }
              });
          
              return view;
          
          }
          

          }

          我得到了这样的字符串,但在第一个片段中找不到使用的方法。你能给我看看吗

          public class Tab2 extends Fragment {
          
          
          public Tab2() {
              // Required empty public constructor
          }
          EditText ed1,ed2;
          private Button b1;
          
          @Nullable
          @Override
          public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                                   @Nullable Bundle savedInstanceState) {
              View view = inflater.inflate(R.layout.fragment_tab2, container, false);
          
              b1 = view.findViewById(R.id.btn_login);
              ed1 = view.findViewById(R.id.idx);
              ed2 = view.findViewById(R.id.password);
          
              b1.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                  String n = ed1.getText().toString();
                  String p = ed2.getText().toString();
          
                  }
              });
          
              return view;
          
          }
          
          }