Help creating tab content


Last Updated:

  1. Capsud

    Capsud New Member This Topic's Starter

    Joined:
    Dec 8, 2009
    Messages:
    3
    Likes Received:
    0
    Hi,

    I've created 3 tabs and I want to add in content. Ive created an array of restaurants that I want in one of the tabs.

    Unfortunatly I'm doing something wrong and my createTabContent(String tag) isn't working...
    Please can someone help?

    Here is my code...
    Code (Text):
    1.  
    2.  public class TabWidget extends TabActivity {
    3.    
    4.     ListView ls2;
    5.  
    6.     /** Called when the activity is first created. */
    7.     @Override
    8.     public void onCreate(Bundle savedInstanceState) {
    9.         super.onCreate(savedInstanceState);
    10.         setContentView(R.layout.main);
    11.        
    12.         TabHost mTabHost = getTabHost();
    13.        
    14.         mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("A-Z").setContent(R.id.textview1));
    15.         mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("Cuisine").setContent(R.id.textview2));
    16.         mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("Location").setContent(R.id.textview3));
    17.        
    18.         mTabHost.setCurrentTab(0);
    19.         createTabContent("Restaurants");
    20.     }
    21.    
    22.     public View createTabContent(String tag)
    23.     {
    24.         ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, RESTAURANTS);
    25.         ls2.setAdapter(adapter);
    26.         return ls2;        
    27.     }      
    28.     }
    29.  
    please please help...
     

    Advertisement

Share This Page

Loading...