Calypso Kid
Aspiring developer
Profile
Posts: 780
Reg: Mar 09, 2012
Upstate New Yor...
18,200
12/31/14 02:53 PM (9 years ago)

Android Action Bar and HTML Doc...........

Hello everyone, I'm finally diving into Android and trying to turn my iOS apps into Android. I've got my app up and running on my mac and on an actual device. I'm pretty impressed with myself..(lol). Thank you Mark (GoNorthWest) for all of the great info that you've published and thank you to all of the other Android newbies who asked all of my questions already. The only two things that I can't figure out are: 1) Making the action bar text white- I've seen and tried all of the posts in these forums and searched the web to no end. None of the suggestions seem to work on a Buzztouch project. Has anyone out there actually been able to make the action bar text white? If so, how? 2) I'm using the html doc plugin for more than 200 screens in my app. I want to keep using the html doc plugin because I'm referencing the html docs for other apps as well. They work perfectly in iOS. When I open the screen (html doc) in the emulator or on the live device, it wants me to download the document then open it and then I have to resize the screen because it is so zoomed in when the document loads. Any suggestions on getting the screen to launch without the user having to go through several steps? Oh, and the photos in the html documents aren't showing up in the app. It just shows the little square where the photo should be. I'm using a url to call the photos. Self hosted BT 3.0 Android 4.0 Thanks everyone, Happy New Year! Dave
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
like
12/31/14 11:39 PM (9 years ago)
On number 2, Smug has a plugin that works better. Images are terribly fussy in Android. All lower case. Only special character can be the underscore. Make sure there aren't spaces in your URLs. Good luck!
 
Dusko
Veteran developer
Profile
Posts: 998
Reg: Oct 13, 2012
Beograd
22,680
like
01/01/15 09:04 AM (9 years ago)
Ok, here is the code you need to change color of the action bar text globally. In BT_activity_host.java look for actionBar.setTitle(navBarTitleText); and find it around line 1256. Comment it out and put beneath it the following lines: // change the foreground color of text here String taraba = "##"; int color = Color.CYAN; CharSequence s = setSpanBetweenTokens(taraba + navBarTitleText + taraba, taraba, new ForegroundColorSpan(color)); actionBar.setTitle(s); Then, press Ctrl-Shift-arrow down on Windows and go to the end of the current method, which should be configureNavBarAndBackgroundForScreen After that function add the following code, taken from here: http://www.androidengineer.com/2010/08/easy-method-for-formatting-android.html //================================== public static CharSequence setSpanBetweenTokens(CharSequence text, String token, CharacterStyle... cs) { // Start and end refer to the points where the span will apply int tokenLen = token.length(); int start = text.toString().indexOf(token) + tokenLen; int end = text.toString().indexOf(token, start); if (start > -1 && end > -1) { // Copy the spannable string to a mutable spannable string SpannableStringBuilder ssb = new SpannableStringBuilder(text); for (CharacterStyle c : cs) ssb.setSpan(c, start, end, 0); // Delete the tokens before and after the span ssb.delete(end, end + tokenLen); ssb.delete(start - tokenLen, start); text = ssb; } return text; } //================================== That's it. Then next time your run your app, its action bar text will in CYAN. Change the line int color = Color.CYAN; to whichever the color you want, including hex codes. You can use the function getColorFromHexString(String hexString) from BT_color.java, using it like this: int color = BT_color.getColorFromHexString("#d3d3d3"); and so on. COMMENT: It may be possible to "take out" this code and put the value into the plugin, with control panel and the like. I haven't gone that route but if someone does, please share your solution. If you need more specialized code and plugins, I am available for hire, both for Android and iOS.
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
like
01/01/15 09:40 AM (9 years ago)
Thanks, Dusko!
 
Calypso Kid
Aspiring developer
Profile
Posts: 780
Reg: Mar 09, 2012
Upstate New Yor...
18,200
like
01/01/15 09:58 AM (9 years ago)
Dusko that's awesome!!! Thank you! I can't wait to try it. I'll let you know how it works out. Thanks again Dave
 
Dusko
Veteran developer
Profile
Posts: 998
Reg: Oct 13, 2012
Beograd
22,680
like
01/01/15 10:31 AM (9 years ago)
> Thanks again You are welcome, let us know how it goes for you. http://duskosavic.com
 
Calypso Kid
Aspiring developer
Profile
Posts: 780
Reg: Mar 09, 2012
Upstate New Yor...
18,200
like
01/01/15 12:58 PM (9 years ago)
Sweeeeeeeeet!!! Got it! My Action Bar text is now white! Awesome! Yes I'm screaming! This is AWESOME!!! I'm not a coder and I have about 1 hour in Eclipse. Initially it couldn't find the end of the method as mentioned above..... >Then, press Ctrl-Shift-arrow down on Windows and go to the end of the current method, which should be configureNavBarAndBackgroundForScreen < .....I'm on a Mac and there are 5 - configureNavBarAndBackgroundForScreen- in my java file. Luckily for me, I figured out that the amazing Buzztouch team breaks up methods with dividers that look like ////////////////////////////////////////////////////////////////////////////////////////////////////////////. Or at least thats how I saw it. I put the second set of code just before the divider even though -configureNavBarAndBackgroundForScreen- wasn't there. OK, now I've got 5 errors First Eclipse didn't like, int color = Color.CYAN; So I made it, int color = BT_color.getColorFromHexString("#ffffff"); per Dusko's instructions ERROR 1 gone! Second, Eclipse didn't like setSpanBetweenTokens new ForegroundColorSpan(color)); SpannableStringBuilder ssb = new SpannableStringBuilder(text); They were all underlined in red with errors in the left margin. It took awhile but I discovered that Eclipse isn't as stupid and hard headed as I thought. By hovering over the underlined problem, Eclipse gave me a bunch of choices in a pop up dialogue box. For no particular reason I chose ... import "blah,blah,blah" To my astonishment, the errors went away. I cleaned and ran in Gennymotion and the Action Barb text was white!!!!!!!!!!!!!!!!!!!! AWESOME!!! Yes I'm still screaming! Dusko- THANK YOU!!! THANK YOU!!! THANK YOU!!! ok i gotta stop yelling now whew!! Now....I have to get ahold of Smugs Android HTML plugin thats not in the plugin store. Dusko, awesome skills. Thanks for sharing! Happy New Year Everyone Dave Edit Oh yeah, I works on my real test device too----woohoo!
 
Dusko
Veteran developer
Profile
Posts: 998
Reg: Oct 13, 2012
Beograd
22,680
like
01/01/15 01:18 PM (9 years ago)
I'm glad you liked it! >Eclipse isn't as stupid and hard headed as I thought. Not at all, it is a very productive environment, although it has some drawbacks too. >Smugs Android HTML plugin thats not in the plugin store. Ask him directly, that plugin is really a must if you are converting apps from iOS to Android. >Dusko, awesome skills. Thanks for sharing! You are welcome. The reason that I was able to shoot it out just like that is that I am solving that problem for a customer of mine and I just did it today, so... >import "blah,blah,blah" Yes, it is a big thing with Java (not so much Eclipse actually) that you have to tell it where do things come from. On Windows, it is solved without thinking by pressing Ctrl Shift O, which imports automatically. People hate Eclipse but it is trying hard to overcome problems that stem from Java itself. The more helpful the Eclipse is, the more red marks people see and think that the end of the world is approaching.
 
Calypso Kid
Aspiring developer
Profile
Posts: 780
Reg: Mar 09, 2012
Upstate New Yor...
18,200
like
01/01/15 02:25 PM (9 years ago)
I'm motivated now that I'm getting to know her (Eclipse). Plans are already in the works to bring a couple more of my iOS app to The Android Market. :-)
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
01/01/15 08:21 PM (9 years ago)
You can also set color of action bar by doing this in configureNavBarAndBackgroundForScreen method: replace actionBar.setTitle(navBarTitleText); with this actionBar.setTitle(Html.fromHtml("<font color=\"red\">" + navBarTitleText + "</font>")); there will be a error on "Html" so just put your mouse over it and import the Html class
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
01/01/15 08:33 PM (9 years ago)
or if you want to use hex values use this: actionBar.setTitle(Html.fromHtml("<font color=\'#0000CC\'>" + navBarTitleText + "</font>"));
 
Calypso Kid
Aspiring developer
Profile
Posts: 780
Reg: Mar 09, 2012
Upstate New Yor...
18,200
like
01/02/15 07:20 AM (9 years ago)
Thanks CMCOFFEE, I'll add this to my notes. Appreciate the help Happy New Year Dave
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
like
01/02/15 04:04 PM (9 years ago)
If anyone is willing to put this into a how-to and send it to me as a PDF, I will give you some points. This is definitely worthy of the How-To page.
 
Dusko
Veteran developer
Profile
Posts: 998
Reg: Oct 13, 2012
Beograd
22,680
like
01/02/15 09:24 PM (9 years ago)
>put this into a how-to and send it to me as a PDF I'll do that.
 
Dusko
Veteran developer
Profile
Posts: 998
Reg: Oct 13, 2012
Beograd
22,680
like
01/21/15 07:34 PM (9 years ago)
 

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.