1. Are you ready for the Galaxy S20? Here is everything we know so far!

Combining Views/Android dev question

Discussion in 'Android Development' started by xmiasma, Dec 30, 2009.

  1. xmiasma

    xmiasma Newbie
    Thread Starter

    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
     


  2. xmiasma

    xmiasma Newbie
    Thread Starter

    Heres a code example:

    Code (Text):
    1.  
    2.      private ListView ls1;
    3.      private ListView ls2;    
    4.      private TabHost myTabHost;
    5.      private List<String> myList;
    6.      
    7.      @Override
    8.      public void onCreate(Bundle icicle)
    9.      {
    10.           super.onCreate(icicle);
    11.            
    12.           ls1 = new ListView(UserEntryActivity.this);              
    13.           ls2 = new ListView(UserEntryActivity.this);
    14.          
    15.           myList.add("Hello");
    16.           myList.add("Second");
    17.           myList.add("Third");
    18.            
    19.           setContentView(R.layout.main);
    20.           myTabHost = (TabHost)this.findViewById(R.id.th_set_menu_tabhost);
    21.           myTabHost.setup();          
    22.            
    23.           TabSpec ts = myTabHost.newTabSpec("TAB_TAG_1");
    24.            
    25.           ts.setIndicator("Tab1");                
    26.                      
    27.           ts.setContent(new TabHost.TabContentFactory(){
    28.                public View createTabContent(String tag)
    29.                {                                            
    30.                     ArrayAdapter<String> adapter = new ArrayAdapter<String>(UserEntryActivity.this,android.R.layout.simple_list_item_1, (String[]) myList.toArray());
    31.                     ls1.setAdapter(adapter);  
    32.                     return ls1;
    33.                }          
    34.           });  
    35.  
    36.  
    The tab code is an example from online. But this is the part i dont think im doing right:

    Code (Text):
    1.  
    2. ArrayAdapter<String> adapter = new ArrayAdapter<String>(UserEntryActivity.this,android.R.layout.simple_list_item_1, (String[]) myList.toArray());
    3.  
    it says that the last param can be an array but its not working right...
     
  3. xmiasma

    xmiasma Newbie
    Thread Starter

    :thinking: no ideas anybody?
     
  4. vvestnes

    vvestnes Lurker

Loading...
Similar Threads - Combining Views Android
  1. Helpjason
    Replies:
    2
    Views:
    261
  2. rewathym
    Replies:
    0
    Views:
    448
  3. gutthatrat
    Replies:
    1
    Views:
    210
  4. Android News
    Replies:
    0
    Views:
    72
  5. Nightpoison
    Replies:
    5
    Views:
    1,055
  6. moatazsawi
    Replies:
    5
    Views:
    652
  7. moatazsawi
    Replies:
    1
    Views:
    293
  8. george90
    Replies:
    8
    Views:
    369
  9. marden
    Replies:
    0
    Views:
    281
  10. hluck1125
    Replies:
    0
    Views:
    462

Share This Page

Loading...