Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Who here can help me with Android development?

  • 08-12-2009 08:28PM
    #1
    Registered Users, Registered Users 2 Posts: 569 ✭✭✭


    Hi there,

    I'm doing an Android project (working in Eclipse) and need some help with views and other small things. Probably not very difficult for the pro's but I dont wanna write out the whole problem if there's no one here that knows Android well enough..

    Thanks let me know


Comments

  • Registered Users, Registered Users 2 Posts: 18,272 ✭✭✭✭Atomic Pineapple


    Bubba wrote: »
    Hi there,

    I'm doing an Android project (working in Eclipse) and need some help with views and other small things. Probably not very difficult for the pro's but I dont wanna write out the whole problem if there's no one here that knows Android well enough..

    Thanks let me know

    I done my final year project on Android, what are you specifically having trouble with?


  • Registered Users, Registered Users 2 Posts: 569 ✭✭✭Bubba


    draffodx wrote: »
    I done my final year project on Android, what are you specifically having trouble with?

    Ok great maybe you can help.
    By following the guide on this webpage i've created a view with 3 tabs.
    http://developer.android.com/guide/tutorials/views/hello-tabwidget.html

    So what I want to do next is to have a list of items on each tab, and then the item shall be clickable that will lead to another window.

    Can you help me out? What do i need to do in the layout file? Or do I need to create more .xml files?

    Thanks.


  • Registered Users, Registered Users 2 Posts: 18,272 ✭✭✭✭Atomic Pineapple


    You can add the items to the Tab in your java class file

    something like this.
    public View createTabContent(String tag)
                   {                                            
                        ArrayAdapter<String> adapter = new ArrayAdapter<String>(Main_screen.this,android.R.layout.simple_list_item_1,new String[]{"item4","item5","item6"});
                        ls2.setAdapter(adapter); 
                        return ls2;
                   }         
              });
    


  • Registered Users, Registered Users 2 Posts: 569 ✭✭✭Bubba


    Ok thanks for your help

    Just one thing, what is the variable 'ls2' that you have?

    Thanks.


  • Registered Users, Registered Users 2 Posts: 569 ✭✭✭Bubba


    Bubba wrote: »
    Ok thanks for your help

    Just one thing, what is the variable 'ls2' that you have?

    Thanks.

    never mind i guess thats ur listView sorry.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 569 ✭✭✭Bubba


    Maybe you could help me out again as nothing is showing up in the tabs still....what have I done wrong or what do I have to do?

    This is my class...
    public class TabWidget extends TabActivity {
    	
    	ListView ls2;
    
    	/** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            
            TabHost mTabHost = getTabHost();
            
            mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("A-Z").setContent(R.id.textview1));
            mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("Cuisine").setContent(R.id.textview2));
            mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("Location").setContent(R.id.textview3));
            
            mTabHost.setCurrentTab(0);   
            createTabContent();
        }
        
        public View createTabContent(String tag)
        {
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, RESTAURANTS);
            ls2.setAdapter(adapter);
            return ls2;        
        }
    

    One question....what is the paramater String tag you have in the createTabContent?

    I guess i'm doing wrong in the setAdapter(adapter) ?

    Thanks a million for your help please


  • Registered Users, Registered Users 2 Posts: 18,272 ✭✭✭✭Atomic Pineapple


    have a read of this thread, it should help

    http://www.anddev.org/how_to_create_tab_in_android-t1102.html

    thats old though so you should make yourself aware of the changes in new Android versions


Advertisement