peterj
Apple Fan
Profile
Posts: 113
Reg: Jun 19, 2011
location unknow...
6,630
10/01/15 08:45 AM (9 years ago)

Android tabbed layout causes blank screen

This may be similar to the topic in this thread: https://www.buzztouch.com/forum/thread.php?tid=523CFF7BB52219CB55ACA5E I downloaded Android code for one of my apps this morning. Trying Android Studio for the first time. The app launched in the emulator, but only the icon and the navigation title bar appeared - the rest of the screen was white. The app didn't crash or hang. No critical errors in the logcat. To troubleshoot, I created a brand new app with two screens: the Home screen that comes by default, and another menuSimple screen to appear on the home screen. Both are menuSimple screens. When I set it to use a non-tabbed layout, it works ok: the app will launch and appear completely in the emulator. When I set it to use a tabbed layout (via BT control panel) and refresh the app, the icon and navBar will appear, but nothing else will appear. The app won't crash - you can still refresh it. You can go back and forth from non-tabbed to tabbed, and the app will update. I studied over the logcats in both of these scenarios - tabbed and non-tabbed. As far as I can tell, when it's tabbed, the plug-in doesn't initialize? Here are the relevant parts of the log cat for both tabbed and non-tabbed refreshes: Tabbed: 10:05:01.802﹕ BT_activity_host:setupTabs (3 tabs) 10:05:01.803﹕ BT_application: getHomeScreenData 10:05:01.803﹕ BT_application:getScreenDataByItemId itemId: “…” 10:05:01.816﹕ BT_activity_host:configureNavBarAndBackgroundForScreen Calling helper methods in BT_viewUtilities... 10:05:01.816﹕ BT_viewUtilities:updateBackgroundColorsForScreen. Screen with JSON itemId: “…” 10:05:01.817﹕ BT_viewUtilities:updateBackgroundImageForScreen. Screen with JSON itemId: “…” and that's the last logcat item. Non-tabbed: 10:06:21.769﹕ BT_activity_host:setupTabs (0 tabs) 10:06:21.769﹕ BT_application: getHomeScreenData 10:06:21.769﹕ BT_activity_host:setupTabs (no tabs, finding home screen) 10:06:21.769﹕ BT_activity_host:showAppHomeScreen 10:06:21.769﹕ BT_application: getHomeScreenData 10:06:21.769﹕ BT_activity_host:initPluginWithScreenData. Calling helper method in BT_application 10:06:21.769﹕ BT_application:initPluginWithScreenData. Creating plugin with JSON itemId: “…” 10:06:21.769﹕ BT_screen_menuListSimple:setScreenData JSON itemId: “…” 10:06:21.769﹕ BT_activity_host:showFragmentForPlugin. Showing plugin with JSON itemId: “…” 10:06:21.769﹕ BT_activity_host:configureNavBarAndBackgroundForScreen Calling helper methods in BT_viewUtilities... and the logcat goes on to loading up menuListSimple. The difference I see is that the tabbed one stops, and doesn't go into the plug-in initialization that the non-tabbed one will. Does anyone have a tabbed layout working in Android Studio with a recent download of Android core code?
 
peterj
Apple Fan
Profile
Posts: 113
Reg: Jun 19, 2011
location unknow...
6,630
like
10/01/15 12:05 PM (9 years ago)
I got it. This was a tough one! In BT_activity_host.java, around line 400, after the "if" loop starts to check if there are tabs, but before for the "for" loop starts to setup the tabs, add the following line: actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); I compared the code from the last time I updated this app (with Eclipse, probably last year or the year before), and found that the BT_activity_host file had a line in it that set the navigation mode for the action bar. The code I downloaded this morning did not have this line. I added the line and it the tabs appear, as well as the rest of the screen.
 
Saifu
Android Fan
Profile
Posts: 46
Reg: Apr 07, 2014
MUmbai
660
like
10/02/15 10:17 AM (9 years ago)
Thanks for osting the fix ... I reported this earlier but couldn`t get any answer (May be because I am not regular on forum ).
 
nadthevlad
Code is Art
Profile
Posts: 1025
Reg: Jun 07, 2012
Denver
21,850
like
10/02/15 05:37 PM (9 years ago)
Good find. I know someone that is having a problem with their android tab view right now.
 
Louie
Code is Art
Profile
Posts: 40
Reg: Dec 31, 2012
Toronto
400
like
10/03/15 12:35 PM (9 years ago)
Although “setNavigationMode” & “NAVIGATION_MODE_TABS” have been deprecated, the code still works to solve the problem for now. Great discovery peterj. The new method is to use SlidingTabLayout.java and the SlidingTabStrip.java
 
Sagacity726
Aspiring developer
Profile
Posts: 5
Reg: May 31, 2012
St. Louis
1,200
like
10/05/15 03:21 PM (9 years ago)
peterj, you are my hero! :) Thanks so much for your diligent debugging! This worked like a charm!
 
Agu
Lost but trying
Profile
Posts: 98
Reg: Mar 06, 2014
GRANADA
980
like
11/30/15 04:31 PM (8 years ago)
it works for me, many thanks!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.