2011-09-08 9 views
0

アプリケーションは初期タブはので、私が欲しいもの、リストビューで「Comunidade」で起動すると、あなたが変更()

TabHost th = (TabHost) findViewById(R.id.tabhost); 
    th.setup(); 
    TabSpec specs = th.newTabSpec("Comunidade"); 
    specs.setContent(R.id.tab1); 
    specs.setIndicator("Comunidade"); 
    th.addTab(specs); 
    specs = th.newTabSpec("Notícias"); 
    specs.setContent(R.id.tab2); 
    specs.setIndicator("Notícias"); 
    th.addTab(specs); 
    specs = th.newTabSpec("Web"); 
    specs.setContent(R.id.tab3); 
    specs.setIndicator("Web"); 
    th.addTab(specs); 

を見ることができるように私は私のTabHostで3つのタブがありますアイテムのリストをクリックすると、ビューはタブに移動します"Web"。ここで

は方法は次のとおりです。事前に

listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
     public void onItemClick(AdapterView<?> av, View v, int pos, long id) { 

    ourweb.loadUrl(listadesites.get(pos).getEndereço()); 
    //CODE THAT I NEED 
     } 
    }); 

感謝。このような

答えて

1

使用TabHost.setCurrentTab、:答えのためではなく、アプリが予期せず停止しました。このコードで

TabHost th = (TabHost) findViewById(android.R.id.tabhost); 
    th.setCurrentTab(2); 
+0

感謝。 **編集**: 問題は、tabhostをインスタンス変数のように宣言しなければならないということでした。 – unpix

+0

少なくとも3つのタブがTabHostに追加されている限りはそうではありません。例外ログの取り扱いは? –

+0

これは今、感謝K-バロ! – unpix

関連する問題