private View createTabView(final Context context, final String text, Integer imageID) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); String color = prefs.getString("color", "green"); View view = LayoutInflater.from(context).inflate(R.layout.tab_background, null); view.setBackgroundDrawable( getResources().getDrawable(FINTheme.getTabSelector(color, getBaseContext()))); // Set up icon ImageView iv = (ImageView) view.findViewById(R.id.tabIcon); iv.setImageResource(imageID); // Set up label TextView tv = (TextView) view.findViewById(R.id.tabLabel); tv.setText(text); return view; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home); Bundle extras = getIntent().getExtras(); String username = ""; if (extras != null) { username = extras.getString("username"); } // Generate our list of categories from the database if (getIntent().hasCategory("App Startup")) { if (isLoggedIn(getBaseContext())) { Toast.makeText(getBaseContext(), "Welcome back " + username, Toast.LENGTH_LONG).show(); } } Resources res = getResources(); TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost); tabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider); addTab( new TextView(this), "Categories", res.getIdentifier("@drawable/categories_tab_icon", null, getPackageName()), tabHost, new Intent().setClass(this, FINMenu.class)); addTab( new TextView(this), "Buildings", res.getIdentifier("@drawable/buildings_tab_icon", null, getPackageName()), tabHost, new Intent().setClass(this, BuildingList.class)); // And recolor the strip. SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); String color = prefs.getString("color", "green"); View tabStrip = (View) findViewById(R.id.fronttab_strip); tabStrip.setBackgroundResource(FINTheme.getBrightColor(color, getBaseContext())); }