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

Combining Views/Android dev question

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

  1. xmiasma

    xmiasma Member
    Thread Starter
    15

    Dec 28, 2009
    13
    0
    15
    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
     

    Advertisement

  2. xmiasma

    xmiasma Member
    Thread Starter
    15

    Dec 28, 2009
    13
    0
    15
    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 Member
    Thread Starter
    15

    Dec 28, 2009
    13
    0
    15
    :thinking: no ideas anybody?
     
  4. vvestnes

    vvestnes Member
    5

    Dec 7, 2009
    5
    0
    5
    Senior System Developer at Zedge.net
    Norway

Share This Page

Loading...