ANDROID
WebView
Visión de páginas desde android
activity_setaw_main.xml |
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="${relativePackage}.${activityClass}" > <WebView android:id="@+id/Aweb" android:layout_width="317dp" android:layout_height="322dp" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_alignParentTop="true" /> </RelativeLayout> |
SetawMainActivity.java Vemos la dirección que se ve al abrir la aplicación. |
package
com.example.appweb; import android.app.Activity; import android.os.Bundle; import android.webkit.WebView; public class SetawMainActivity extends Activity { private WebView MWeb; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_setaw_main); MWeb=(WebView)findViewById(R.id.Aweb); MWeb.loadUrl("http://www.seta43.netau.net/androhx.html"); } } |
AndroidManifest.xml Debemos cambiar los permisos para acceder a internet. |
<?xml version="1.0"
encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.appweb" android:versionCode="1" android:versionName="1.0" > <uses-permission android:name="android.permission.INTERNET" /> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".SetawMainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> |