can anyone give sample code for TabHost in Android?

前端 未结 4 2043
春和景丽
春和景丽 2021-02-10 06:50

I need sample code to create TabHost in android. can anyone help me.

4条回答
  •  故里飘歌
    2021-02-10 07:32

    I had done tabhost related code with respect to displaying scores

        TabHost host = getTabHost();
        host.setup ();
    
        TabSpec allScoresTab = host.newTabSpec("allTab");
        allScoresTab.setIndicator(getResources().getString(R.string.all_scores), getResources().getDrawable(android.R.drawable.star_on));
        allScoresTab.setContent(R.id.ScrollViewAllScores);
        host.addTab(allScoresTab);
    
        TabSpec friendScoresTab = host.newTabSpec("friendsTab");
        friendScoresTab.setIndicator(getResources().getString(R.string.friends_scores), getResources().getDrawable(android.R.drawable.star_on));
        friendScoresTab.setContent(R.id.ScrollViewFriendScores);
        host.addTab(friendScoresTab);
    
        host.setCurrentTabByTag("allTab");
    

    My xml contains :

    
    
        
            
            
            
            
            
            
        
       
        
            
            
                
       
      
    - 
       
      
            
        
    
    
    

提交回复
热议问题