Ich versuche, Web-Projekt mit Android, von Webview zu bauen. Ich habe ein Eingabefeld des Typs Datei <input type="file" >
, um Benutzer Dateien auf den Server hochladen zu lassen, aber es scheint nicht auf Android-Webview zu funktionieren, wenn ich auf die Schaltfläche Durchsuchen tippen, passiert nichts.Android Webview Eingabe Typ Datei
Comp.java
package com.gururaju.bbmp;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.webkit.WebChromeClient;
public class Comp extends Activity {
WebView comp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_comp);
WebView myWebView = (WebView) findViewById(R.id.comp);
myWebView.setWebChromeClient(new WebChromeClient());
myWebView.loadUrl("file:///android_asset/comp.html");
}
}
activity_comp.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/comp"
>
</WebView>
</LinearLayout>
comp.html (Assets Ordner)
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="comp.css">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h2 align="center">Post your Complaints here</h2>
<form enctype="multipart/form-data" action="" name="complaints" method="POST">
<input class="title" type="text" name="title" placeholder="Enter the Complaint Title" /><br />
<div class="spacer-welcome"></div>
<textarea name="desc" class="desc" placeholder="Your complaint description here..."></textarea><br />
<div class="spacer-welcome1"></div>
<input id="center" type="file" name="image" ><br />
<input class="upload" type="submit" name="submit" value="Submit" >
</form>
</body>
</html>
Jede Hilfe wäre willkommen.
"https://github.com/delight-im/Android-AdvancedWebView" hat den Trick gemacht – Nilabja