android - 使用带有输入字符串值的 webview
问题描述
我只是想问你如何使用从edittext输入的字符串来使用webview?例如,我创建了 2 个片段,其中一个显示 webview,另一个从用户那里获得 2 个编辑文本。我只想输入从 2. 片段到 1. 片段的编辑文本值。因为我想创建一个这样的 URL: webView.loadUrl(" http://www.truebilisim.com/myiphone/index.php?id= " + 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。EditText
当用户单击登录按钮时,您将从 's 发送值。设置
onClickListener
在登录按钮上。在侦听器内部,检查您EditTexts
是否有价值。如果它们有价值,请转到另一个片段。将 的值发送
EditText
到另一个片段,您可以通过多种方式执行此操作。一种是,只需获取目标片段对象的实例,然后发送值。
推荐阅读
- java - 来自 Spring 中的属性文件的 POJO
- c# - 为什么我的 HubConnectionBuilder 不能在 HubConnectionBuilder().Build 上工作?
- complexity-theory - NP-Hard 问题实例
- typescript - 'MyType 类型的 Typescript 参数
' 不可分配给“部分”类型的参数 >' - flutter - 将柱子切成两块相同大小的块,一旦一根柱子需要更多空间,就应该扩大
- java - JPA 原生命名查询的用途
- c - 是什么导致程序中的分段错误转储 Mach-O 符号?
- c++ - 如何在 TextCtrl 中保存类中的值
- android - 如何在文件夹中创建文件并将数据写入其中
- typescript - 使用 TypeORM 和 BigNumber.js 存储十进制数