6
I’m creating a WebView
for Android. When I load the App, the imported page works perfectly, but when I click on some link page, that same link opens in another browser.
I wonder how I can make all the links open in the same Activity
of that WebView
?
Source code:
import android.app.Activity;
import android.os.Bundle;
import android.view.ViewGroup.LayoutParams;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.LinearLayout;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LinearLayout ll = (LinearLayout) findViewById(R.id.LinearLayout1);
WebView wv = new WebView(this); //(WebView) findViewById(R.id.webView1);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
wv.setLayoutParams(lp);
WebSettings ws = wv.getSettings();
ws.setJavaScriptEnabled(true);
ws.setSupportZoom(false);
wv.loadUrl("http://www.exemplo.com.br/");
ll.addView(wv);
}
}
Thank you very much young man. It worked right! : D
– Kaleb Figueiredo
Accept Eduardo’s answer as correct then...
– Trxplz0