0

ページに 3 つのタブがあり、各タブで 1 つのアクティビティが呼び出されていますが、アクティビティ Web ビューを呼び出すと、タブが消えて Web ビューのみで完全なページが取得されます。Web ビューでタブ ビューを表示する方法を教えてください。そして、戻るキーを使用してタブビューに戻ると、黒い画面のみが表示されます..

MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    TabHost tabHost=getTabHost();
    // no need to call TabHost.Setup()       
    //First Tab
    TabSpec spec1=tabHost.newTabSpec("Tab 1");
    spec1.setIndicator("Registration",getResources().
    getDrawable(R.drawable.ic_launcher));
    Intent in1=new Intent(this,RegistrationActivity.class);
    spec1.setContent(in1);

    TabSpec spec2=tabHost.newTabSpec("Tab 2");
    spec2.setIndicator("Login",getResources().
    getDrawable(R.drawable.ic_launcher));
    Intent in2=new Intent(this,LoginActivity.class);
    spec2.setContent(in2);

    TabSpec spec3=tabHost.newTabSpec("Tab 2");
    spec3.setIndicator("WebView",getResources().
    getDrawable(R.drawable.ic_launcher));
    Intent in3=new Intent(this,WebViewActivity.class);
    spec3.setContent(in3);

    tabHost.addTab(spec1);
    tabHost.addTab(spec2);
    tabHost.addTab(spec3);
}

Web ビュー アクティビティ

super.onCreate(savedInstanceState);
setContentView(R.layout.webview);

webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://www.google.com");
webView.getParent();

メインタブ xml

<?xml version="1.0" encoding="utf-8"?>

<TabHost android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@android:id/tabhost"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">

        <ScrollView 
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="90"> 

            <FrameLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:id="@android:id/tabcontent" />

        </ScrollView> 

        <TabWidget
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@android:id/tabs"/>

    </LinearLayout>
</TabHost>

Web ビュー xml

<WebView
    android:id="@+id/webView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
4

0 に答える 0