Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 17    Views: 151

Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
04/18/16 03:07 PM (8 years ago)

Tabs in an Android Studio Project

I am running an Android Studio Project that was downloaded from BT a few months ago. It worked until I added tabs into the project. Has anyone used tabs in an Android Studio project? Does anyone know a fix? Thanks!
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
04/19/16 04:05 AM (8 years ago)
I'd like to be able to offer you a positive option Susan, but I don't know of any easy answers and I don't recall anyone in the forums solving this one. So instead, a couple of suggestions for compromise could be: 1) Consider using the context menu & don't use tab layout. This is not meant to be flippant; because of the different ways that different devices and different android flavours work, the way tabs display can be very unpredictable. I personally gave up on using Android tabs for that reason when BT v3 came out. 2) Build your app in Eclipse (which still works). Eclipse can run side by side with Android Studio, on a single PC (or mac). Alan
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
like
04/19/16 07:22 AM (8 years ago)
I am working on trying to track down the problem. There is some deprecated language in the BT_activityHost that I am looking into right now. (Line 395) if(actionBar.getNavigationMode() == ActionBar.NAVIGATION_MODE_TABS){ actionBar.removeAllTabs(); } I totally agree, Alan. I wish the tab bars would just disappear. The clients love them, though. They see them in other apps, in Buzztouch 2.0 apps, and they request to have them in their apps. The reason why the clients I am working with love them so much is because the apps I am making have a lot of content, and the tab bar works well for navigating. In the Android apps I modified the code to hide the tab bar images, and that looks a bit better. Actually, until now I have been using Eclipse. The core code I use for the Android apps is heavily modified to include a PDF reader, so I have been trying to stay in Eclipse as long as possible. But something with Google Play Services stopped working in Eclipse, at least in my build. When I tried to search for a solution on the World Wide Web I couldn't find a solution, because the rest of the world has moved over to Android Studio. So I came to the conclusion that it is time to move to Android Studio. I am sure the tab bar problem is repairable. I haven't read that tab bars are obsolete in Android.
 
Dusko
Veteran developer
Profile
Posts: 998
Reg: Oct 13, 2012
Beograd
22,680
like
04/19/16 08:49 AM (8 years ago)
I cannot find it, but I do remember someone in the forums claiming to have solved this problem with one line of code. So it may still be worthwhile to search the forums a bit more. As for the Eclipse vs. Android Studio, I left Eclipse almost a year ago and never looked back. Now there is Android Studio 2.0, which is excellent in its own right. We here at Buzztouch cannot use all their goodies though, as most will work only for versions 21, 22, 23 and up. Just two examples. Now in AS you can save the image from the device with one click, earlier you had to go to DDMS, take the images there, get back etc. The other thing I like very much in AS if refactoring: create a block of code and tell it to "refactor it" -- which means to create a new method from that block of code and replace it in the main text with a method call. If you are like me and write code all day long, this is a real life saver. One thing the creates confusion is that so much has changed for Android in the last two years and we do not generally see it here, using BT. I mean, we can create apps using BT without paying special attention to Material Design and other novelties. However, when someone "upgrades" to Android Studio we always hear claims how this or that won't work -- but it is mostly because of changes in Android, not because you changed the editor.
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
04/19/16 08:57 AM (8 years ago)
Yes removeAllTabs is depreciated. What exactly you trying to do? LA
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
like
04/19/16 09:24 AM (8 years ago)
LA, what I am seeing is the Navigation bar at the top with the logo on it, but everything is blank underneath. Thanks, Dusko. You are totally right--it isn't the change to the new IDE--it is the change to the version of Android we are compiling to. Android Studio will be much better than Eclipse, once I get through the learning curve of how to use it. I will do some more searching.
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
04/19/16 09:27 AM (8 years ago)
ok LA
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
04/19/16 10:07 AM (8 years ago)
Like you Susan, my eclipse envoronment broke recently after I took a load of updates. So I moved on. I built an app in Android studio that used to work and it just plain refused to run until I removed the images from the menus (yep, I know, old chesnut). So no doubt a little fine tuning is still needed. But it made me realise that whilst I should move forward, I want the ability to step back if I need to. So last week I rebuilt my Eclipse environment from scratch on my Mac and I am pleased to say it works with the latest google play services too. I agree in principle on moving to Android Studio, I accept the world may has moved on, I am only suggesting having Eclipse as a contingency option, which I think is prudent. If all else fails, and for whatever disavantages it has, you know that tab menus can work with it. Which in this specific instance, you need. Alan
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
like
04/19/16 10:09 AM (8 years ago)
I tried the same thing with Eclipse and failed miserably. After spending hours and hours on it, I had to move on. I still don't know what I was doing wrong.
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
04/19/16 10:10 AM (8 years ago)
I think all of us got spoiled with Eclipse. We hated it at the time, but now, we miss it..lol LA
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
04/19/16 10:26 AM (8 years ago)
I messed around with some default Eclipse values until my app compiled. If I recall, the key things are, under java compiler, my default settings all use level 1.6. Under the SDK manager under Tools, I Android SDK Tools 24.4.1 and Adroid SDK Platform-tools 23.0.1. I have nothing else under Tools preview channel, nothing under Android N, nothing under Android 6 down to Android 4.1.2. I do have Android 4.0.3 (API 15) and Android 4.0 (API 14). Under Extras I have Android Support Library, Google Play Services, Google Repository and the emulator accelerator. And I don't take any updates any more...
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
like
04/19/16 10:32 AM (8 years ago)
Thanks, Alan! Not sure I ever want to open up Eclipse again, but if I do, these settings are invaluable.
 
sarahk
Code is Art
Profile
Posts: 159
Reg: Jul 16, 2014
Auckland
10,290
like
04/19/16 03:38 PM (8 years ago)
I followed the advice given to be in http://www.buzztouch.com/forum/thread.php?tid=675C4CF80EAB620AD5E9717&sortColumn=FT.id&sortUpDown=DESC&currentPage=1 which ironically came from Susan - to not use tabs on Android.
 
MacApple
Apple Fan
Profile
Posts: 4674
Reg: Oct 25, 2010
USA
61,140
like
04/19/16 05:03 PM (8 years ago)
As an aside. I don't reckon tab bars are going anywhere. Still very important easy access bar. More so as newer phones have got a wee bit bigger. Always liked the tab bar, always will and don't reckon it's going away anytime soon. Too good a hotspot on screen.
 
peterj
Apple Fan
Profile
Posts: 113
Reg: Jun 19, 2011
location unknow...
6,630
like
04/21/16 01:58 PM (8 years ago)
I had an issue like this recently - everything beneath the icon and navigation bar was white / blank. My solution uses deprecated code, but it worked for me: http://www.buzztouch.com/forum/thread.php?tid=939F013C7E56CB2DA6A67F7
 
Dusko
Veteran developer
Profile
Posts: 998
Reg: Oct 13, 2012
Beograd
22,680
like
04/21/16 09:39 PM (8 years ago)
@peterj That is exactly the thread that I was referring in my previous post in this thread. Curious to find whether this will resolve Susan's problem!?
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
like
04/22/16 07:01 AM (8 years ago)
Kittsy fixed it for me. But I am having problems with Studio so I still can't successfully compile it. Once I get it working, I will post the fix. It was just one line of code missing. Kittsy is a pro at Android as well as iOS.
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
like
04/22/16 11:33 AM (8 years ago)
Here is the fix. This is the repaired method. You will see the comment by Kittsy's fix. BTW, this is the same fix as the link PeterJ gave us. ////////////////////////////////////////////////////////////////////////// //tab setup and interface methods... public void setupTabs(int selectedTab) { BT_debugger.showIt(activityName + ":setupTabs (" + apps4ems_appDelegate.rootApp.getTabs().size() + " tabs)"); //configure action bar... actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_USE_LOGO); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayUseLogoEnabled(true); //pre 4.0 does not allow this... try { actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(false); } catch (NoSuchMethodError e) { BT_debugger.showIt(activityName + ":setupTabs Cannot set homeButtonEnabled on this version of Android"); } //remove tabs if we're using them... if (actionBar.getNavigationMode() == ActionBar.NAVIGATION_MODE_TABS) { actionBar.removeAllTabs(); } } else { BT_debugger.showIt(activityName + ":setupTabs ActionBar is null?"); } //get home screen JSON data (for screen connected to first tab or home screen if not tabbed)... BT_item tmpHomeScreenData = apps4ems_appDelegate.rootApp.getHomeScreenData(); //use tabs if we have them.... if (apps4ems_appDelegate.rootApp.getTabs().size() > 0) { //setup tabs with title and icon. NOTE: Android Action bars generally use text only for tabs and not icons... for (int t = 0; t < apps4ems_appDelegate.rootApp.getTabs().size(); t++) { BT_item thisTab = apps4ems_appDelegate.rootApp.getTabs().get(t); //get title and icon for this tab... String title = BT_strings.getJsonPropertyValue(thisTab.getJsonObject(), "textLabel", ""); Drawable d = null; String iconName = BT_strings.getJsonPropertyValue(thisTab.getJsonObject(), "iconName", ""); if (iconName.length() > 0) { d = BT_fileManager.getDrawableByName(iconName); } Tab tmpTab = actionBar.newTab(); tmpTab.setText(title); tmpTab.setTabListener(this); tmpTab.setTag(t); if (d != null) tmpTab.setIcon(d); actionBar.addTab(tmpTab); } //select default tab if not the default... if (selectedTab > 0) { //remember the selected tab index in the BT_application object... apps4ems_appDelegate.rootApp.setSelectedTab(selectedTab); } // The repair from Kittsy is to add this line actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); } else { //not using tabs... BT_debugger.showIt(activityName + ":setupTabs (no tabs, finding home screen)"); tmpHomeScreenData.setIsHomeScreen(true); //show the home screen fragment... this.showAppHomeScreen(); } //setup home screen nav bar and background properties... if (tmpHomeScreenData != null) { //setup nav bar and background for this fragment... this.configureNavBarAndBackgroundForScreen(tmpHomeScreenData); //remember this fragment's JSON data as the "current screen" so we can refer to it later... apps4ems_appDelegate.rootApp.setCurrentScreenData(tmpHomeScreenData); } }
 

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.