RowanQuickAccess.java :  » App » rowanandroid » Rowan » application » quickaccess » Android Open Source

Android Open Source » App » rowanandroid 
rowanandroid » Rowan » application » quickaccess » RowanQuickAccess.java
package rowan.application.quickaccess;

import rowan.application.quickaccess.tabs.AboutRowan;
import rowan.application.quickaccess.tabs.QuickLinks;
import rowan.application.quickaccess.tabs.RSSDisplay;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TabHost;
import android.widget.TabWidget;
import android.widget.TextView;
import android.widget.TabHost.TabSpec;

/**
 * This is the overall Activity, which is a TabActivity
 *  This includes:
 *    - Rowan University logo
 *    - GPS Button
 *   - Qiuck Links Tab
 *   - RSS Tab
 *   - About Tab
 *   
 *   
 * @author Tom
 *
 */
public class RowanQuickAccess extends TabActivity {
  
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        try {
        setContentView(R.layout.main);
        
        // GOOGLE GPS NAVIGATIOn
        Button map = (Button)findViewById(R.id.map);
        map.setOnClickListener(new OnClickListener() {
          public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=Rowan+University+NJ"));
            startActivity(intent);
          }
        });
        
        Resources res = getResources(); // Resource object to get Drawables
        TabHost tabHost = getTabHost();  // The activity TabHost
        TabSpec spec;  // Reusable TabSpec for each tab
        Intent intent;  // Reusable Intent for each tab

        // Create an Intent to launch an Activity for the tab (to be reused)
        intent = new Intent().setClass(this, QuickLinks.class);

        // Initialize a TabSpec for each tab and add it to the TabHost
        spec = tabHost.newTabSpec("Quick Links").setIndicator("Quick Links",
                res.getDrawable(R.drawable.quick_links))
                      .setContent(intent);
        tabHost.addTab(spec);

        // Do the same for the other tabs
        intent = new Intent().setClass(this, RSSDisplay.class);
        spec = tabHost.newTabSpec("RSS Feed").setIndicator("RSS Feed",
                res.getDrawable(R.drawable.rss_feed))
                      .setContent(intent);
        
        tabHost.addTab(spec);

        
        intent = new Intent().setClass(this, AboutRowan.class);
        spec = tabHost.newTabSpec("About").setIndicator("About Rowan",
            res.getDrawable(R.drawable.about_icon))
                      .setContent(intent);
        tabHost.addTab(spec);

        ////////////////
        tabHost.setCurrentTab(0);
        
        //////// This fixes Android 1.6 and lower from having clear tabs
        TabWidget tw = getTabWidget();
        if (Integer.parseInt(android.os.Build.VERSION.SDK) < 5)
          tw.setBackgroundColor(Color.parseColor("#631400"));
        ////////////////
        
        }
        catch (Exception e) { // display the error
          TextView tv = new TextView(this);
          tv.setText("Error: " + e.getMessage());
          setContentView(tv);
        }  
    } 
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.