我的应用中有一个webview。网页中有一个浏览(上传文件)按钮。当我在HTC(Android 4.0.3)中测试应用程序时,它正在运行,但在Galaxy S3(Android 4.1.1)中,它无法正常工作。
我不会得到文件选择器菜单。当我触摸屏幕的任何地方时,显然按钮不可点击
“singleCursorHandlerTouchEvent -getEditableSupport FASLE”。
我尝试了所有可行的解决方案。
// Profile web view
mWebView = (WebView) findViewById(R.id.itemWebView);
//improve the speed
mWebView.getSettings().setRenderPriority(RenderPriority.HIGH);
mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setSupportZoom(false);
//setup the file chooser
mWebView.setWebChromeClient(new WebChromeClient() {
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
mUploadMessage = uploadMsg;
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
ProfileActivity.this.startActivityForResult(Intent.createChooser(i, "Image Chooser"),FILECHOOSER_RESULTCODE);
}
@SuppressWarnings("unused")
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
openFileChooser(uploadMsg);
}
@SuppressWarnings("unused")
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
openFileChooser(uploadMsg);
}
});
这是我的onActivityResult函数
protected void onActivityResult(int requestCode, int resultCode,
Intent intent) {
if (requestCode == FILECHOOSER_RESULTCODE) {
if (null == mUploadMessage)
return;
Uri result = intent == null || resultCode != RESULT_OK ? null
: intent.getData();
mUploadMessage.onReceiveValue(result);
mUploadMessage = null;
} else {
System.out.println("Something else->" + requestCode);
}
}
在我的jQuery移动网页中,我有一个简单的表单:
<form id="edit" method="post" enctype="multipart/form-data" data-ajax="false" action = "profile_myimage.php">
<div data-role="fieldcontain">
<label for="image" class="required">Select photo</label>
<input type="file" name="image" id="image" />
<p class="error_message" id="img"><p>
</div>
请帮我解决这个问题。感谢您的支持。
答案 0 :(得分:1)
我刚才遇到了同样的问题,问题(似乎只在Android 2.x.x上)对我来说是WebView无法获得焦点。
您可以执行此操作,以便在收到触摸时请求关注WebView:
webView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_DOWN && !view.hasFocus()) {
view.requestFocus();
}
return false;
}
});
答案 1 :(得分:0)
我遇到了使用WebViewClient和表单开发应用程序的相同问题。原来解决方案是让你的输入更大(确保它没有溢出)
我的HTML布局是
<form>
<div>
<input type="text" onclick="..." />
<span>...</span>
</div>
</form>
将一些大小调整CSS应用于元素。父div有溢出:隐藏在它上面,所以当你在浏览器中查看页面时,输入元素有一个滚动条。修复此问题使得onclick开始再次正确启动,并使输入可以从Android应用程序中选择。
看看这个问题(帮助我解决这个问题):Phonegap button does not fire due to "singleCursorHandlerTouchEvent -getEditableSupport FASLE"
答案 2 :(得分:0)
我遇到了类似的问题: singleCursorHandlerTouchEvent -getEditableSupport FASLE
似乎android(在samsung s3 mini上)不喜欢div元素中有一个包含文件输入按钮的滚动条。
这就是我所拥有的:
<div style ="overflow: auto; white-space: nowrap;" class="panel-body commentForm" />
这就是它现在的运作方式:
<div class="panel-body commentForm" />