fanfalveto
25/07/12, 18:00:40
Estoy leyendo un libro y tratando de adaptar un ejemplo para acceder de forma un tanto burda,lo sé, al blog de un gran amigo que está de viaje (que suerte el tío),el caso es que no me sale,os pongo el código.
muchas gracias.
la parte java:
package org.example.browserview;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class Browserview extends Activity {
String dir="http://www.elviejoviaje.blogspot.com.es/";
private WebView webView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView = (WebView) findViewById(R.id.webView1);
cargar();
}
private void cargar(){
webView.getSettings().setJavaScriptEnabled(false);
webView.loadUrl(dir);
}
}
el xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
</LinearLayout>
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
y el manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.example.browserview"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:icon="@drawable/world"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".Browserview" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Gracias de nuevo.
muchas gracias.
la parte java:
package org.example.browserview;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class Browserview extends Activity {
String dir="http://www.elviejoviaje.blogspot.com.es/";
private WebView webView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView = (WebView) findViewById(R.id.webView1);
cargar();
}
private void cargar(){
webView.getSettings().setJavaScriptEnabled(false);
webView.loadUrl(dir);
}
}
el xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
</LinearLayout>
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
y el manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.example.browserview"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:icon="@drawable/world"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".Browserview" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Gracias de nuevo.