Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 20th Apr 2012, 11:45 AM   #1
Leprechaun Killer
War Room Member
 
Thomas's Avatar
 
Join Date: 2002
Location: Ireland
Posts: 707
Thanks: 263
Thanked 634 Times in 302 Posts
Blog Entries: 14
Default
Java for Android: Any Way To Display Dates in Tabs?
Share on: 
fb share twitter share gplus share more share

Hi Warriors,

I have 6 tabs in a horizontally-scrolling tab bar. Everything seems to work fine in terms of function (displaying webviews in each), but I'm at a loss when it comes to labelling them.

As shown in my main Activity below, I currently have them labelled Day 2, Day 3, etc. However, I need to turn those labels into auto-updating dates.

For example, if this was being done online using PHP, I would use something like this:
PHP Code:
<?php echo "".date("l (d M.)", strtotime("+6 day")). '';?>
to automatically insert a date corresponding to 7 days from when the tab is loaded/viewed. However, being a Java newbie, I have no idea how to do anything similar in Java (or if it can be done at all).

Can anyone advise?

Regards,
Tommy.

Code:
import android.app.Activity;
import android.app.TabActivity;
import android.widget.TabHost;
import android.content.Intent;
import android.os.Bundle;
import com.google.ads.*;

@SuppressWarnings("deprecation")

public class MainActivity extends TabActivity {

        private TabHost mTabHost;

            @Override
            public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);

                mTabHost = getTabHost();
                TabHost.TabSpec spec;
                Intent Intent;

                // Day 1
                Intent = new Intent(this, Day0.class);        
                spec = mTabHost.newTabSpec("Day 0")
                        .setIndicator("   Today   ")
                        .setContent(Intent);        
                mTabHost.addTab(spec);

                // Day 2
                Intent = new Intent(this, Day1.class);        
                spec = mTabHost.newTabSpec("Day 1")
                        .setIndicator("   Tomorrow   ")
                        .setContent(Intent);        
                mTabHost.addTab(spec);

                // Day 3
                Intent = new Intent(this, Day2.class);        
                spec = mTabHost.newTabSpec("Day 2")
                        .setIndicator("   Day 2   ")
                        .setContent(Intent);        
                mTabHost.addTab(spec);

                // Day 4
                Intent = new Intent(this, Day3.class);        
                spec = mTabHost.newTabSpec("Day 3")
                        .setIndicator("   Day 3   ")
                        .setContent(Intent);        
                mTabHost.addTab(spec);

                // Day 5
                Intent = new Intent(this, Day4.class);        
                spec = mTabHost.newTabSpec("Day 4")
                        .setIndicator("   Day 4   ")
                        .setContent(Intent);        
                mTabHost.addTab(spec);

                // Day 6
                Intent = new Intent(this, Day5.class);        
                spec = mTabHost.newTabSpec("Day 5")
                        .setIndicator("   Day 5   ")
                        .setContent(Intent);        
                mTabHost.addTab(spec);

                // Day 7
                Intent = new Intent(this, Day6.class);        
                spec = mTabHost.newTabSpec("Day 6")
                        .setIndicator("   Day 6   ")
                        .setContent(Intent);        
                    mTabHost.addTab(spec);                                  
            }               

// AdMob Code   
public class Banner extends Activity {
      @Override
      public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // Look up the AdView as a resource and load a request.
        AdView adView = (AdView)this.findViewById(R.id.adView);
        adView.loadAd(new AdRequest());
      }
    }   
}
Thomas is offline  
Closed Thread


Bookmarks

Tags
android, dates, display, dynamically, java, php, tabs


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 02:32 AM.