2013-03-08 116 views
0

我正在使用标签窗口小部件通过webview来显示应用程序内的网页的Android应用程序。 执行中的应用程序不显示正确的数据。 它只显示我为特定选项卡添加的html页面。但是在所有选项卡中都可以看到html页面。主要内容不可见。tabhost中的选项卡不显示正确的内容

http://prntscr.com/vgcoj

super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    TabHost th = (TabHost) findViewById(R.id.tabhost); 

    WebView home = (WebView) findViewById(R.id.webView1); 
    home.setWebViewClient(new WebViewClient() { 
     @Override 
     public void onPageFinished(WebView view, String url) { 
      findViewById(R.id.progressBar1).setVisibility(View.GONE); 
      findViewById(R.id.webView1).setVisibility(View.VISIBLE); 
     } 
    }); 
    home.loadUrl("http://udaipurblog.com"); 
    home.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN); 

    WebView static1 = (WebView) findViewById(R.id.webView2); 

    static1.loadUrl("file:///android_asset/1.html"); 
    static1.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN); 

    WebView webview2 = (WebView) findViewById(R.id.webView3); 
    webview2.loadUrl("file:///android_asset/2.html"); 
    webview2.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN); 



    th.setup(); 
    TabSpec homespec = th.newTabSpec("home"); 
    homespec.setContent(R.id.tab1); 
    homespec.setIndicator("Home"); 
    th.addTab(homespec); 

    TabSpec static1spec = th.newTabSpec("static1"); 
    homespec.setContent(R.id.tab2); 
    homespec.setIndicator("Static1"); 
    th.addTab(homespec); 

    TabSpec static2spec = th.newTabSpec("static2"); 
    homespec.setContent(R.id.tab2); 
    homespec.setIndicator("Static2"); 
    th.addTab(homespec); 

回答

2

您已经使用homespec每一个标签。使用各个选项卡的规格。 对不起,我不能评论,因为我的声誉。

1

你加入总是homespec标签

TabSpec homespec = th.newTabSpec("home"); 
homespec.setContent(R.id.tab1); 
homespec.setIndicator("Home"); 
th.addTab(homespec); 

TabSpec static1spec = th.newTabSpec("static1"); 
homespec.setContent(R.id.tab2); 
homespec.setIndicator("Static1"); 
th.addTab(homespec); 

TabSpec static2spec = th.newTabSpec("static2"); 
homespec.setContent(R.id.tab2); 
homespec.setIndicator("Static2"); 
th.addTab(homespec); 
相关问题