1. Check out our app, Forums for Android! Download and leave feedback here!

Help creating tab content

Discussion in 'Application Development' started by Capsud, Dec 8, 2009.

  1. Capsud

    Capsud New Member
    Thread Starter
    5

    Dec 8, 2009
    3
    0
    5
    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...