2

EditText検索用に の上に がありますWebView。検索後、ユーザーはTextBoxサーバーからのリンクを介してレンダリングされたものを取得します。EditTextの と のTextBox両方でカーソルが点滅しますWebView。しかし、 の に何かを入力しようとしても、TextBoxの にはWebView文字EditTextが入りません。TextBoxWebView

エミュレータでこの問題が発生する理由についての考え。

レイアウト

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="match_parent"
 android:background="@drawable/white"
 android:tileMode="repeat" >

 <RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">


   <LinearLayout 
      android:layout_height="wrap_content" 
      android:orientation="horizontal"
      android:layout_width="fill_parent"
      android:layout_marginTop="30dip"
      android:focusable="true" 
      android:focusableInTouchMode="true">  

      <EditText android:text="" 
        android:id="@+id/searchEditText"
        android:layout_height="wrap_content" 
        android:layout_weight="1"
        android:layout_width="fill_parent">
      </EditText>
      <Button android:text="Search" 
        android:id="@+id/searchCatalogButton"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content">
      </Button>

  </LinearLayout>

    <WebView
      android:id="@+id/browserwebview"
      android:fillViewport="true"
      android:layout_marginTop="75dip"
      android:layout_marginBottom="30dip"
      android:layout_height="fill_parent"
      android:layout_width="fill_parent"/>
    <LinearLayout
        android:id="@+id/header"
        android:layout_alignParentTop="true"
        android:layout_width="fill_parent" 
        android:layout_height="30dip"
        android:background="@drawable/black"
        android:tileMode="repeat">
    <ImageButton 
        android:id="@+id/buttonBackCatalog"
        android:src="@drawable/greenarrow"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/black"
        android:tileMode="repeat"/>
    <ImageView 
        android:src="@drawable/logo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="gone"/>
  </LinearLayout>

  <LinearLayout
    android:layout_alignParentBottom="true"
    android:layout_width="fill_parent" 
    android:layout_height="30dip"
    android:layout_weight="1"
    android:weightSum="5" 
    android:orientation="horizontal"
    android:background="@drawable/black"
    android:tileMode="repeat">

    <LinearLayout 
        android:id="@+id/footerLayoutHome"
        android:clickable="true"
        android:layout_width="fill_parent"
        android:layout_weight="1" 
        android:orientation="vertical"
        android:gravity="center" 
        android:layout_height="fill_parent">

    <ImageButton 
        android:id="@+id/footerMainBtnHome"
        android:layout_width="fill_parent" 
        android:layout_height="14dip"
        android:src="@drawable/home" 
        android:background="@drawable/black"/>
    <TextView 
        android:text="Home" 
        android:textSize="8dip"
        android:textColor="#ffffff"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    </LinearLayout>
    <LinearLayout 
        android:id="@+id/footerLayoutProducts"
        android:clickable="true"
        android:layout_width="fill_parent"
        android:layout_weight="1" 
        android:orientation="vertical"
        android:gravity="center" 
        android:layout_height="fill_parent">

        <ImageButton 
            android:id="@+id/footerMainBtnProducts"
            android:layout_width="fill_parent" 
            android:layout_height="14dip"
            android:src="@drawable/products" 
            android:background="@drawable/black"/> 
        <TextView 
            android:text="Products" 
            android:textSize="8dip"
            android:textColor="#ffffff"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
   </LinearLayout>
   <LinearLayout 
        android:id="@+id/footerLayoutCart"
        android:clickable="true"
        android:layout_width="fill_parent"
        android:layout_weight="1" 
        android:orientation="vertical"
        android:gravity="center" 
        android:layout_height="fill_parent">

        <ImageButton 
            android:id="@+id/footerMainBtnCart"
            android:layout_width="fill_parent" 
            android:layout_height="14dip"
            android:src="@drawable/cart" 
            android:background="@drawable/black"/>
        <TextView 
            android:text="Cart" 
            android:textSize="8dip"
            android:textColor="#ffffff"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

   </LinearLayout>
   <LinearLayout 
        android:id="@+id/footerLayoutFeedback"
        android:clickable="true"
        android:layout_width="fill_parent"
        android:layout_weight="1" 
        android:orientation="vertical"
        android:gravity="center" 
        android:layout_height="fill_parent">

        <ImageButton 
        android:id="@+id/footerMainBtnFeedback"
        android:layout_width="fill_parent" 
        android:layout_height="14dip"
        android:src="@drawable/feedback" 
        android:background="@drawable/black"/>
        <TextView 
        android:text="Feedback" 
        android:textSize="8dip"
        android:textColor="#ffffff"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

   </LinearLayout>  

   <LinearLayout 
      android:id="@+id/footerLayoutHelp"
      android:clickable="true"
      android:layout_width="fill_parent"
      android:layout_weight="1" 
      android:orientation="vertical"
      android:gravity="center" 
      android:layout_height="fill_parent">

       <ImageButton 
        android:id="@+id/footerMainBtnHelp"
        android:layout_width="fill_parent" 
        android:layout_height="14dip" 
        android:src="@drawable/help" 
        android:background="@drawable/black"/>
       <TextView 
        android:text="Help" 
        android:textSize="8dip"
        android:textColor="#ffffff"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    </LinearLayout>                
  </LinearLayout>
 </RelativeLayout>
</LinearLayout>

Java コード

    webView = (WebView) findViewById(R.id.browserwebview);
    searchEditText = (EditText)findViewById(R.id.searchEditText);
    search = (Button)findViewById(R.id.searchCatalogButton);

    search.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            String urlSearchKey = searchEditText.getText().toString().trim();
            if(urlSearchKey==""){
                Toast.makeText(Catalog.this, "Enter Search Keyword", Toast.LENGTH_LONG).show();

            }
            else{
                url=urlforthesite+urlSearchKey;
                webView.loadUrl(url);
                searchEditText.setText("");
            }

        }
    });`

お返事を楽しみにしています。

ありがとう。

4

2 に答える 2

0

webkit のカスタマイズにより、webview のテキストボックスの動作がデバイスごとに異なる場合があります。元の Android ソース コードでは、textBox は Android ビューの editText と結合されます。しかし、デバイスでは、異なる外観を与えることができます。したがって、これは問題ではなく、その API の単なる動作です。さまざまなデバイスで確認してください。

于 2012-08-06T05:21:42.457 に答える
0

この2つのことを行います。問題を解決するかもしれません::))

1)android:focusable="true" webViewに追加

<WebView android:id="@+id/browserwebview"
    android:layout_weight="1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:focusable="true"  
    android:fillViewport="true"
    android:layout_marginTop="75dip"
    android:layout_marginBottom="30dip"
  />    

2)追加webView.getSettings().setJavaScriptEnabled(true); Java コードで

于 2012-08-06T06:30:35.900 に答える