2013-03-08 5 views
0

Приложение для 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); 
Смежные вопросы