Je fais un webview dans android. il y a un webview et un texte d'édition et un bouton aller. Je veux que lorsque le webview change le texte d'édition change automatiquement avec l'URL actuelle. exemple: quand je tape une url "www.google.com" je vais sur google si je vais sur youtube depuis google mais mon texte d'édition est "www.google.com". mais je veux que mon modifier le texte changer automaticlly comme WebView actuelle Ceci est mon code javaNavigateur webview Android modifier le texte changer automatiquement avec le changement de la page Web
package com.example.ashraful.userinterface;
import android.app.Activity;
import android.graphics.Bitmap;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
public class Main2Activity extends Activity {
WebView web1;
EditText ed1;
Button bt1;
String Address;
String add;
ProgressBar pbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main2); web1 =(WebView)findViewById(R.id.webView1);
ed1 = (EditText)findViewById(R.id.editText1);
bt1 = (Button)findViewById(R.id.button1);
pbar = (ProgressBar)findViewById(R.id.progressBar1);
pbar.setVisibility(View.GONE);
bt1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Address = "http://" + ed1.getText().toString();
WebSettings webSetting = web1.getSettings();
webSetting.setBuiltInZoomControls(true);
webSetting.setJavaScriptEnabled(true);
webSetting.setLoadsImagesAutomatically(true);
web1.setWebViewClient(new WebViewClient());
web1.loadUrl(Address);
}
});
}
public class WebViewClient extends android.webkit.WebViewClient
{
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);
pbar.setVisibility(View.VISIBLE);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
// TODO Auto-generated method stub
super.onPageFinished(view, url);
pbar.setVisibility(View.GONE);
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if ((keyCode == KeyEvent.KEYCODE_BACK) && web1.canGoBack()) {
web1.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
}
Le présent est le code xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.ashraful.userinterface.Main2Activity">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="GO" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button1"
android:layout_alignParentLeft="true"
android:ems="10"
android:hint="Type Your URL Here"
android:layout_toLeftOf="@+id/button1"
android:layout_toStartOf="@+id/button1" />
<View
android:id="@+id/view12"
android:layout_width="wrap_content"
android:layout_height="3dp"
android:layout_alignBottom="@+id/button1"
android:layout_alignParentLeft="true"
android:background="#3bbdfa" />
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/editText1"
android:layout_centerHorizontal="true" />
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
</RelativeLayout>
pouvez-vous s'il vous plaît me dire comment supportAchat html 5 vidéo que je veux dire youtube video –
@AshrafulIslam: Que voulez-vous dire exactement par « soutien »? –
à partir du code ci-dessus je fais un navigateur quand je vais sur youtube et lire une vidéo, la vidéo montre uniquement l'écran noir .Audio joue clairement, mais la vidéo est noire. Alors, comment puis-je résoudre cela, pouvez-vous s'il vous plaît m'aider? et merci pour votre réponse précédente il résout mon problème précédent .. –