Focus不从的EditText在Android的web视图切换到文本框 [英] Focus does not change from EditText to TextBox in WebView android
问题描述
我有一个的EditText
在的WebView
之上,搜索。搜索后,用户将获得一些文本框
通过从服务器来链接呈现。光标在两个闪烁的EditText
并在对应的文本框
的WebView
。但是,即使当我尝试键入文本框的东西
的的WebView
,信中获取到的EditText
,但不是在的文本框
的的WebView
。
I have a EditText
on top of a WebView
, for search. After search, user gets some TextBox
rendered through a link coming from server. Cursor blinks in both EditText
and in the TextBox
of the WebView
. But even when I try to type something in the TextBox
of the WebView
, letters gets on to the EditText
but not in the TextBox
of the WebView
.
为什么这个问题在模拟器中发生的任何想法。
Any idea on why this problem is happening in the emulator.
布局
<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 code
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("");
}
}
});`
期待您的回复。
感谢。
推荐答案
做到这一点的 2的事情 .Might解决你的问题::))
Do this 2 things.Might Solve Your Problem: :))
1)添加机器人:可聚焦=真正的
web视图中的
1) Add android:focusable="true"
in 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(真)
。在Java code
2) Add webView.getSettings().setJavaScriptEnabled(true)
; in Your Java Code
这篇关于Focus不从的EditText在Android的web视图切换到文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!