2009/1/22 Timothy DeWees <whtdrgn...@gmail.com>

>
> Hello,
>
> I have an application with a preferences pane that allows you to show/
> hide tabs.  I've walked through the code below and I AM passing the
> right index to the setDefaultTab(int) method; however, when the screen
> renders the tab is NOT selected.
>
> Any idea?
>
>               SharedPreferences settings = getSharedPreferences
> (Preferences.PREFS_NAME, 0);
>                int index = 0;
>                int bookIndex = 0;
>                int cdIndex = 0;
>                int gameIndex = 0;
>                int movieIndex = 0;
>                int loanIndex = 0;
>                String defaultTab = "";
>                TabHost host=getTabHost();
>
>                if(settings.getBoolean(Preferences.KEY_SHOW_BOOK_TAB,
> true)){
>                        bookIntent = new Intent(this, movies.class);
>                        bookIntent.putExtra(MoviesDbAdapter.KEY_MOVIE_TYPE,
> KEY_BOOK);
>                        host.addTab(host.newTabSpec("one")
>                .setIndicator("Book")
>                .setContent(bookIntent));
>                        bookIndex = index;
>                        index++;
>                }
>                if(settings.getBoolean(Preferences.KEY_SHOW_CD_TAB, true)) {
>                cdIntent = new Intent(this, movies.class);
>                cdIntent.putExtra(MoviesDbAdapter.KEY_MOVIE_TYPE, KEY_CD);
>                host.addTab(host.newTabSpec("two")
>                                .setIndicator("CD")
>                                .setContent(cdIntent));
>                cdIndex = index;
>                index ++;
>                }
>                if(settings.getBoolean(Preferences.KEY_SHOW_GAME_TAB, true))
> {
>                gameIntent = new Intent(this, movies.class);
>                gameIntent.putExtra(MoviesDbAdapter.KEY_MOVIE_TYPE,
> KEY_GAME);
>                host.addTab(host.newTabSpec("three")
>                        .setIndicator("Game")
>                        .setContent(gameIntent));
>                gameIndex = index;
>                index ++;
>                }
>                if(settings.getBoolean(Preferences.KEY_SHOW_MOVIE_TAB,
> true)) {
>                movieIntent = new Intent(this, movies.class);
>                movieIntent.putExtra(MoviesDbAdapter.KEY_MOVIE_TYPE,
> KEY_MOVIE);
>                host.addTab(host.newTabSpec("four")
>                                .setIndicator("Movie")
>                                .setContent(movieIntent));
>                movieIndex = index;
>                index++;
>                }
>                if(settings.getBoolean(Preferences.KEY_SHOW_LOAN_TAB, true))
> {
>                rentalIntent = new Intent(this, Rentals.class);
>                host.addTab(host.newTabSpec("five")
>                               .setIndicator("Loans")
>                                .setContent(rentalIntent));
>                loanIndex = index;
>                }
>                //Set default tab index
>                defaultTab = settings.getString(Preferences.KEY_DEFAULT_TAB,
> "").toUpperCase();
>                if(defaultTab.equals("BOOK")){
>                        index = bookIndex;
>                } else if(defaultTab.equals("CD")){
>                        index = cdIndex;
>                } else if(defaultTab.equals("GAME")){
>                        index = gameIndex;
>                } else if(defaultTab.equals("MOVIE")){
>                        index = movieIndex;
>                } else if(defaultTab.equals("LOAN")){
>                        index = loanIndex;
>                } else {
>                        index = 0;
>                }
>                setDefaultTab(index);
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to