我正在嘗試創建一個警報框,它彈出並顯示webview,用戶可以在其中登錄以檢查其電子郵件。警報框正在完美工作並顯示網頁。問題是當我想輸入mu電子郵件地址時,沒有鍵盤顯示輸入。當警報框彈出包含web視圖時,鍵盤不顯示
請幫助或者建議我其他方法。對於alertbox
代碼:
gmail.setOnClickListener(new OnClickListener()
\t {
\t @Override
\t public void onClick(View v)
\t {
\t \t
\t \t
\t \t AlertDialog.Builder alert = new AlertDialog.Builder(RegisterActivity.this);
\t \t alert.setTitle("Check Gmail");
\t \t WebView wv = new WebView(RegisterActivity.this);
\t \t
\t \t wv.setOnTouchListener(new View.OnTouchListener() {
\t \t \t \t @Override
\t \t \t \t public boolean onTouch(View v, MotionEvent event) {
\t switch (event.getAction()) {
\t case MotionEvent.ACTION_DOWN:
\t case MotionEvent.ACTION_UP:
\t if (!v.hasFocus()) {
\t v.requestFocus();
\t }
\t break;
\t }
\t return false;
\t \t \t \t }
\t });
\t \t
\t \t wv.loadUrl("https://mail.google.com");
\t \t wv.setWebViewClient(new WebViewClient() {
\t \t @Override
\t \t public boolean shouldOverrideUrlLoading(WebView view, String url) {
\t \t view.loadUrl(url);
\t \t return true;
\t \t }
\t \t });
\t \t alert.setView(wv);
\t \t alert.setNegativeButton("Close", new DialogInterface.OnClickListener() {
\t \t @Override
\t \t public void onClick(DialogInterface dialog, int id) {
\t \t dialog.dismiss();
\t \t }
\t \t });
\t \t alert.show();
\t }
\t });
按照要求XML代碼:
<LinearLayout 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"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.mohalogin.RegisterActivity"
android:background="@drawable/register" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter your name" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/editTextName" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Choose your username" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/editTextUserName" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Choose your password" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:id="@+id/editTextPassword" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter your email" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:id="@+id/editTextEmail" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Register"
android:id="@+id/buttonRegister" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="Already Registered" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Login"
android:id="@+id/buttonLogin" />
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="25dp">
<Button
android:id="@+id/googleMail"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/gmail"/>
<Button
android:id="@+id/yahooMail"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/yahoo"/>
</LinearLayout>
</LinearLayout>
發佈您的xml代碼。 –
@jaydroider先生這裏是我的xml代碼 – akshay270494