KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am fighting with focus management of WebView: WebView messes with focus management of classic components. Here is a simple application with just an EditBox and a WebView in it which loads Google! <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:and="http://schemas.android.com/apk/res/android" xmlns:webtag="http://schemas.android.com/apk/res/com.webtag" and:orientation="vertical" and:layout_width="fill_parent" and:layout_height="fill_parent"> <LinearLayout and:id="@+id/HorizontalScrollView02" and:layout_width="fill_parent" and:layout_height="wrap_content"> <EditText and:id="@+id/EditText01" and:layout_width="wrap_content" and:layout_height="wrap_content" and:text="@+id/EditText01"/> </LinearLayout> <WebView and:id="@+id/uiContent" and:layout_weight="1" and:layout_width="fill_parent" and:layout_height="fill_parent"/> </LinearLayout> And here is the Java code: public class WebtagActivity extends Activity { // UI components. private WebView mContent; private EditText mUrl; @Override public void onCreate (Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mContent = (WebView) findViewById(R.id.uiContent); mContent.getSettings().setJavaScriptEnabled(true); mContent.loadUrl("http://www.google.fr/"); } } Based on this very simple example, it's impossible to get focus on the WebView (i.e. the google search terms input box)! However when adding "mContent.requestFocus();" during initialization, things get better. I can switch from my EditText to my WebView if I click on WebView first only... But behaviour gets soon very "erratic", with WebView sometimes not getting focus when touching it, sometimes ge
Tags (comma-separated)
Save Edits
Cancel