| | #1 |
| Leprechaun Killer War Room Member Join Date: 2002 Location: Ireland
Posts: 707
Thanks: 263
Thanked 634 Times in 302 Posts
Blog Entries: 14 |
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: 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());
}
}
} |
| |
|
| Bookmarks |
| Tags |
| android, dates, display, dynamically, java, php, tabs |
| |