I have been trying to add a WebView inside one of the tabs in TabView but it isn't working. When I go to the other tabs i just have TextViews and they work fine, but as soon as I click the tab with the web in it, error it closes unexpectedly. here is my search_result.java that has the tabview
package supa.mack.doppler;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TabHost;
public class search_result extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.search_result);
TabHost mTabHost;
mTabHost = getTabHost();
mTabHost.addTab(mTabHost.newTabSpec("Results").setIndicator("Results").setContent(R.id.textview1));
mTabHost.addTab(mTabHost.newTabSpec("Location").setIndicator("Location").setContent(R.id.textview2));
mTabHost.addTab(mTabHost.newTabSpec("Facebook")
.setIndicator("Facebook")
.setContent(new Intent(this, BioActivity.class)));
mTabHost.setCurrentTab(0);
Button searchButton=(Button) findViewById(R.id.return_button);
searchButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
Intent intent=new Intent(
search_result.this,
doppler_test.class
);
startActivity(intent);
}
});
}
}
Now here is the search_result.xml where the tabView is defined
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_gravity="center_horizontal">
<TableLayout
android:id="@+id/TableLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_gravity="center_horizontal" android:gravity="center_horizontal">
<Button
android:id="@+id/return_button"
android:layout_height="wrap_content"
android:text="Return"
android:layout_width="fill_parent"/>
<TableRow>
<TextView
android:id="@+id/textview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Here is the list of people in your location" />
<TextView
android:id="@+id/textview2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Here you will see your exact location to bookmark it" />
<TextView
android:id="@+id/textview3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Reference Facebook To Check The One You Seek" />
</TableRow>
</TableLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
Here is BioActivity.java where the webView is defined
package supa.mack.doppler;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class BioActivity extends Activity {
WebView browser;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.web_view);
browser = (WebView) findViewById(R.id.webview);
browser.getSettings().setJavaScriptEnabled(true);
browser.loadUrl("http://www.google.com");
}
}
And finally this is the web_view.xml where the webView is placed
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
O and almost forgot to add my manifest....
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="supa.mack.doppler"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
<activity android:name=".doppler_test"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".search_result">
<activity android:name=".search_result" android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar"/>
<activity android:name=".BioActivity" android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar"/>
</activity>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.INTERNET" />
</application>
<uses-sdk android:minSdkVersion="7" />
</manifest>
Thank you for looking over my code it is really ruining my day not being able to get this to work...