• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Combining Views/Android dev question

xmiasma

Newbie
I have a question regarding using one view inside of another view...for example lets say that i have 2 tabs....one tab will have a text box and button for input and the second tab will hold a list of items (in this case the items are text input).

I think i am having trouble in understanding how android apps are running. In c++ you have a main loop that runs the code you write. In this format im not sure where that is exactly. or does it just run in activities and they have their OWN main loops?

help much appreciated
 
Heres a code example:

Code:
     private ListView ls1; 
     private ListView ls2;    
     private TabHost myTabHost; 
     private List<String> myList;
      
     @Override 
     public void onCreate(Bundle icicle) 
     { 
          super.onCreate(icicle); 
           
          ls1 = new ListView(UserEntryActivity.this);              
          ls2 = new ListView(UserEntryActivity.this); 
          
          myList.add("Hello");
          myList.add("Second");
          myList.add("Third");
           
          setContentView(R.layout.main); 
          myTabHost = (TabHost)this.findViewById(R.id.th_set_menu_tabhost); 
          myTabHost.setup();          
           
          TabSpec ts = myTabHost.newTabSpec("TAB_TAG_1"); 
           
          ts.setIndicator("Tab1");                 
                     
          ts.setContent(new TabHost.TabContentFactory(){ 
               public View createTabContent(String tag) 
               {                                             
                    ArrayAdapter<String> adapter = new ArrayAdapter<String>(UserEntryActivity.this,android.R.layout.simple_list_item_1, (String[]) myList.toArray()); 
                    ls1.setAdapter(adapter);  
                    return ls1; 
               }          
          });

The tab code is an example from online. But this is the part i dont think im doing right:

Code:
ArrayAdapter<String> adapter = new ArrayAdapter<String>(UserEntryActivity.this,android.R.layout.simple_list_item_1, (String[]) myList.toArray());

it says that the last param can be an array but its not working right...
 
Back
Top Bottom