Android应用程序启动浏览器而不是应用程序

Android应用程序启动浏览器而不是应用程序,android,webview,android-tabhost,Android,Webview,Android Tabhost,我创建了一个带有5个标签的TabHost android应用程序,所有这些标签都使用了内容的网络视图(有些是本地的,有些是www)。这一切运行顺利,但当应用程序首次启动时,浏览器启动时,其中一个站点将加载到其中一个选项卡的webview中。按后退按钮关闭浏览器并将您带到应用程序本身。你知道为什么会这样吗 我的所有选项卡都有相同的基本代码: public void onCreate(Bundle savedInstanceState) { super.onCreate(saved

我创建了一个带有5个标签的TabHost android应用程序,所有这些标签都使用了内容的网络视图(有些是本地的,有些是www)。这一切运行顺利,但当应用程序首次启动时,浏览器启动时,其中一个站点将加载到其中一个选项卡的webview中。按后退按钮关闭浏览器并将您带到应用程序本身。你知道为什么会这样吗

我的所有选项卡都有相同的基本代码:

 public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        TabHost tabHost=(TabHost)findViewById(R.id.tabHost);
        tabHost.setup();


        TabSpec spec1=tabHost.newTabSpec("Tab 1");
        spec1.setContent(R.id.tab1);
        spec1.setIndicator("Start",getResources().getDrawable(R.drawable.ic_tab_start_selected));
        WebView start = (WebView) findViewById(R.id.webview); 
        start.loadUrl("file:///android_asset/start.html");
对于main.xml文件,如下所示:

<TabHost android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tabHost"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TabWidget
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@android:id/tabs"
/>
 <FrameLayout
 android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/tabcontent"

 >
 <LinearLayout
 android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/tab1"
android:orientation="vertical"
android:paddingTop="60px"
 >
 <WebView  
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>    

 </LinearLayout>

你知道为什么会这样吗

是-因为您正在显式创建
WebView
的“全屏”实例,该实例与使用此代码的活动/TabHost和选项卡内容分开

WebView start = (WebView) findViewById(R.id.webview); 
start.loadUrl("file:///android_asset/start.html");
…将这两行注释掉,看看会发生什么