J'ai un champ de recherche avec sous le champ de recherche une webview. quand je tape dans la boîte de recherche "bonjour", le webview montre le fichier html "hello.html" Mais quand je change ("file: /// android_asset /" + srt) en ("file: /// android_asset/main/"+ srt) Le webview dit que le fichier main/hello.html ne peut pas trouver.Erreur par Webview
mon code complet est le suivant:
package com.kerk.liedboek;
import com.kerk.liedboek.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class psalmen extends Activity {
WebView webview;
/** Called when the activity is first created. */
final Activity activity = this;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.main);
webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
EditText edit = (EditText) findViewById(R.id.editText1);
String str = edit.getText().toString() +".html";
webview.loadUrl("file:///android_asset/main/"+str); }
});
}
}
Qu'est-ce que je fais mal?
quand j'ai ("file: /// android_asset /" + str) ça marche bien mais avec l'autre pas. J'espère que vous me comprenez et que vous pouvez m'aider.
Gromdroid
merci beaucoup. Ce code fonctionne bien pour moi. – Gromdroid