java - WebView Using Problem in Android -
when press load url button on activity, starts new browser instead of displaying content in webview widget in default activity.
here res/layout/main.xml :
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <linearlayout android:id="@+id/linearlayout01" android:layout_width="wrap_content" android:layout_height="wrap_content"> <button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="load yahoo" android:id="@+id/buttonloadyahoo"></button> </linearlayout> <linearlayout android:id="@+id/linearlayout02" android:layout_width="match_parent" android:layout_height="fill_parent"> <webview android:id="@+id/browsermine" android:layout_height="fill_parent" android:layout_width="fill_parent"></webview> </linearlayout> </linearlayout> and src/com/tariknotebook/notebook.java file content :
package com.tariknotebook; import android.app.activity; import android.os.bundle; import android.view.view; import android.webkit.webview; import android.widget.button; public class notebook extends activity { /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); button buttonloadyahoo = (button) findviewbyid(r.id.buttonloadyahoo); final webview web = (webview) findviewbyid(r.id.browsermine); buttonloadyahoo.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { web.loadurl("http://www.seslisozluk.com"); } }); } }
you need implement webviewclient , set webview class. need set javascript enabled.
mwebview.getsettings().setjavascriptenabled(true);
check example , steps 6.
http://developer.android.com/resources/tutorials/views/hello-webview.html
Comments
Post a Comment