android中,用了webview载入了一页面,页面内容如下<body>
test
2323
<input type="file" name="Filedata" size="45" />
</body>
可在运行程序上,手机屏点击这选择文件的按纽,没反应。(在android手机自带的浏览器上运行此页面是正常的)现问:这是什么问题,怎么处理呀

解决方案 »

  1.   

    这里有段代码,可以点击,并有效果,只是选择了文件后,返回不了所选文件的目录
         wv.setWebChromeClient(new TestWebChromeClient(
    new WebChromeClient()) {
    public void openFileChooser(ValueCallback<Uri> uploadFile) {
    // TODO Auto-generated method stub
    mUploadMessage = uploadFile;
    System.out.println("f"+uploadFile);
    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    SearReActivity.this.startActivityForResult(Intent.createChooser(
    i, "选择"), FILE_SELECTED);
    }
         public void onProgressChanged(WebView view, int newProgress) {
         if(newProgress==100){
         handlert2.sendEmptyMessage(1);
         }
         super.onProgressChanged(view, newProgress);
         }
    });大家帮我看下什么原因?
    另附上引用的TestWebChromeClient类
    /*
     * Copyright (C) 2010 The Android Open Source Project
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *      http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */package com.nc;import android.graphics.Bitmap;
    import android.net.Uri;
    import android.os.Message;
    import android.view.View;
    import android.webkit.ConsoleMessage;
    import android.webkit.GeolocationPermissions;
    import android.webkit.JsPromptResult;
    import android.webkit.JsResult;
    import android.webkit.ValueCallback;
    import android.webkit.WebChromeClient;
    import android.webkit.WebStorage;
    import android.webkit.WebView;/**
     *
     * WebChromeClient for browser tests.
     * Wraps around existing client so that specific methods can be overridden if needed.
     *
     */
    abstract class TestWebChromeClient extends WebChromeClient {    private WebChromeClient mWrappedClient;    protected TestWebChromeClient(WebChromeClient wrappedClient) {
            mWrappedClient = wrappedClient;
        }    /** {@inheritDoc} */
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            mWrappedClient.onProgressChanged(view, newProgress);
        }    /** {@inheritDoc} */
        @Override
        public void onReceivedTitle(WebView view, String title) {
            mWrappedClient.onReceivedTitle(view, title);
        }    /** {@inheritDoc} */
        @Override
        public void onReceivedIcon(WebView view, Bitmap icon) {
            mWrappedClient.onReceivedIcon(view, icon);
        }    /** {@inheritDoc} */
        @Override
        public void onReceivedTouchIconUrl(WebView view, String url,
                boolean precomposed) {
            mWrappedClient.onReceivedTouchIconUrl(view, url, precomposed);
        }    /** {@inheritDoc} */
        @Override
        public void onShowCustomView(View view, CustomViewCallback callback) {
            mWrappedClient.onShowCustomView(view, callback);
        }    /** {@inheritDoc} */
        @Override
        public void onHideCustomView() {
            mWrappedClient.onHideCustomView();
        }    /** {@inheritDoc} */
        @Override
        public boolean onCreateWindow(WebView view, boolean dialog,
                boolean userGesture, Message resultMsg) {
            return mWrappedClient.onCreateWindow(view, dialog, userGesture, resultMsg);
        }    /** {@inheritDoc} */
        @Override
        public void onRequestFocus(WebView view) {
            mWrappedClient.onRequestFocus(view);
        }    /** {@inheritDoc} */
        @Override
        public void onCloseWindow(WebView window) {
            mWrappedClient.onCloseWindow(window);
        }    /** {@inheritDoc} */
        @Override
        public boolean onJsAlert(WebView view, String url, String message,
                JsResult result) {
            return mWrappedClient.onJsAlert(view, url, message, result);
        }    /** {@inheritDoc} */
        @Override
        public boolean onJsConfirm(WebView view, String url, String message,
                JsResult result) {
            return mWrappedClient.onJsConfirm(view, url, message, result);
        }    /** {@inheritDoc} */
        @Override
        public boolean onJsPrompt(WebView view, String url, String message,
                String defaultValue, JsPromptResult result) {
            return mWrappedClient.onJsPrompt(view, url, message, defaultValue, result);
        }    /** {@inheritDoc} */
        @Override
        public boolean onJsBeforeUnload(WebView view, String url, String message,
                JsResult result) {
            return mWrappedClient.onJsBeforeUnload(view, url, message, result);
        }    /** {@inheritDoc} */
        @Override
        public void onExceededDatabaseQuota(String url, String databaseIdentifier,
                long currentQuota, long estimatedSize, long totalUsedQuota,
                WebStorage.QuotaUpdater quotaUpdater) {
            mWrappedClient.onExceededDatabaseQuota(url, databaseIdentifier, currentQuota,
                    estimatedSize, totalUsedQuota, quotaUpdater);
        }    /** {@inheritDoc} */
        @Override
        public void onReachedMaxAppCacheSize(long spaceNeeded, long totalUsedQuota,
                WebStorage.QuotaUpdater quotaUpdater) {
            mWrappedClient.onReachedMaxAppCacheSize(spaceNeeded, totalUsedQuota, quotaUpdater);
        }    /** {@inheritDoc} */
        @Override
        public void onGeolocationPermissionsShowPrompt(String origin,
                GeolocationPermissions.Callback callback) {
            mWrappedClient.onGeolocationPermissionsShowPrompt(origin, callback);
        }    /** {@inheritDoc} */
        @Override
        public void onGeolocationPermissionsHidePrompt() {
            mWrappedClient.onGeolocationPermissionsHidePrompt();
        }    /** {@inheritDoc} */
        @Override
        public boolean onJsTimeout() {
            return mWrappedClient.onJsTimeout();
        }    /** {@inheritDoc} */
        @Override
        @Deprecated
        public void onConsoleMessage(String message, int lineNumber, String sourceID) {
            mWrappedClient.onConsoleMessage(message, lineNumber, sourceID);
        }    /** {@inheritDoc} */
        @Override
        public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
            return mWrappedClient.onConsoleMessage(consoleMessage);
        }    /** {@inheritDoc} */
        @Override
        public Bitmap getDefaultVideoPoster() {
            return mWrappedClient.getDefaultVideoPoster();
        }    /** {@inheritDoc} */
        @Override
        public View getVideoLoadingProgressView() {
            return mWrappedClient.getVideoLoadingProgressView();
        }    /** {@inheritDoc} */
        @Override
        public void getVisitedHistory(ValueCallback<String[]> callback) {
            mWrappedClient.getVisitedHistory(callback);
        }    /** {@inheritDoc} */
        
        public void openFileChooser(ValueCallback<Uri> uploadFile) {
            ((TestWebChromeClient) mWrappedClient).openFileChooser(uploadFile);
        }
    }
      

  2.   

    webSettings.setJavaScriptEnabled(true);
      

  3.   

         wv=(WebView) findViewById(R.id.sear_re);
         //可用js
         wv.getSettings().setJavaScriptEnabled(true);
         //滚动条风格,为0就是不给滚动条留空间,滚动条覆盖在网页上
         wv.setScrollBarStyle(0);
         wv.setWebViewClient(new WebViewClient(){
         @Override
         public boolean shouldOverrideUrlLoading(WebView view, String url) 
         {
             loadUrl(view, url);
             return true;

         }
         });
        
          wv.setWebChromeClient(new WebChromeClient(){
         @Override
         public void onProgressChanged(WebView view, int newProgress) {
         if(newProgress==100){
         handlert2.sendEmptyMessage(1);
         }
         super.onProgressChanged(view, newProgress);
         }
         });加了也没有用,问题还待大家帮忙解决。。
      

  4.   

    http://www.eoeandroid.com/thread-97910-1-1.html
    参照5楼
      

  5.   

    package com.TextView.Activity;import android.app.Activity;
    import android.app.AlertDialog;
    import android.app.AlertDialog.Builder;
    import android.content.DialogInterface;
    import android.content.Intent;
    import android.graphics.Bitmap;
    import android.net.Uri;
    import android.os.Bundle;
    import android.util.Log;
    import android.webkit.JsPromptResult;
    import android.webkit.JsResult;
    import android.webkit.ValueCallback;
    import android.webkit.WebChromeClient;
    import android.webkit.WebView;
    import android.webkit.WebViewClient;
    import android.widget.Toast;public class ManiActivity extends Activity {
    private ValueCallback<Uri> mUploadMessage;
    final static int FILE_SELECTED = 4;
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
           
    //       TextView tv = (TextView)findViewById(R.id.tv);
    //       tv.setText(Html.fromHtml("欢迎大家观看<font color= blue>《Android开发从零开始》</font>系列教程"));
            
            final WebView webView =(WebView)findViewById(R.id.webview);
            webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
            webView.getSettings().setJavaScriptEnabled(true);
            webView.setFocusable(true);
            webView.requestFocus();
            try{
             webView.loadUrl("http://0791.8ff.cn/test/test.html");
            }
            catch(Exception e)
            {
             e.printStackTrace();
            }
            
            WebViewClient wvc = new WebViewClient(){ @Override
    public void onLoadResource(WebView view, String url) {
    Toast.makeText(getApplicationContext(), "onLoadResource", Toast.LENGTH_SHORT).show();
    super.onLoadResource(view, url);
    } @Override
    public void onPageFinished(WebView view, String url) {
    Toast.makeText(getApplicationContext(), "onPageFinished", Toast.LENGTH_SHORT).show();
    super.onPageFinished(view, url);
    } @Override
    public void onPageStarted(WebView view, String url, Bitmap favicon) {
    Toast.makeText(getApplicationContext(), "onPageStarted", Toast.LENGTH_SHORT);
    super.onPageStarted(view, url, favicon);
    } @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
    webView.loadUrl(url);
    return true;
    }
            
            };
            
            webView.setWebViewClient(wvc);
            
            MyWebChromeClient mwcc = new MyWebChromeClient(new WebChromeClient()){ @Override
    public void openFileChooser(ValueCallback<Uri> uploadFile) {
    if (mUploadMessage != null)
    return;
    mUploadMessage = uploadFile;
    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    i.setType("*/*");
    ManiActivity.this.startActivityForResult(Intent.createChooser(
    i, getString(R.string.choose_upload)), FILE_SELECTED);
    }
            
            };
            webView.setWebChromeClient(mwcc);
            
           //on 
        }
        
    protected void onActivityResult(int requestCode, int resultCode,
    Intent intent) { switch (requestCode) { // Choose a file from the file picker.
    case FILE_SELECTED:
    if (null == mUploadMessage)
    break;
    Uri result = intent == null || resultCode != RESULT_OK ? null
    : intent.getData();
    mUploadMessage.onReceiveValue(result);
    mUploadMessage = null;
    Log.e("onActivityResult", "onActivityResult");
    break;
    }
    }
    }
    package com.TextView.Activity;import android.net.Uri;
    import android.webkit.ValueCallback;
    import android.webkit.WebChromeClient;public class MyWebChromeClient extends WebChromeClient {
    private WebChromeClient mWrappedClient;
    protected MyWebChromeClient(WebChromeClient webChromeClient){
    mWrappedClient = webChromeClient;
    }

    public void openFileChooser(ValueCallback<Uri>uploadFile)
    {
    ((MyWebChromeClient)mWrappedClient).openFileChooser(uploadFile);
    }



    }