Wednesday, May 25, 2011

Class for Creating Bold Text in Android

This class has saved me TONS of time ...


public class StyleableSpannableStringBuilder extends SpannableStringBuilder {

public StyleableSpannableStringBuilder appendWithStyle(CharacterStyle c, CharSequence text) {
super.append(text);
final int startPos = length() - text.length();
setSpan(c, startPos, length(), 0);
return this;
}

public StyleableSpannableStringBuilder appendBold(CharSequence text) {
return appendWithStyle(new StyleSpan(Typeface.BOLD), text);
}

public StyleableSpannableStringBuilder appendItalic(CharSequence text) {
return appendWithStyle(new StyleSpan(Typeface.ITALIC), text);
}
}

Wednesday, May 18, 2011

Dealing with the "gen" folder in Android -- Clean, Error, Clean, Build, Etc

From StackOverflow:

http://stackoverflow.com/questions/3820517/clean-in-eclipse-temporarily-destroys-android-project-with-error-message-missing


So valuable I needed to repost it

We have finally tracked the last problem regarding this bug.

The "clean" action used to always delete the "gen" folder which was wrong. This was fixed in ADT 8 or 9, I can't remember.

However, if the "gen" folder is marked as derived it still gets deleted which leads to the error.

When the "New Project Wizard" is run, the gen folder is created normally, without the "derived" flag, so this is fine.

The following scenario however is broken:

  • delete manually gen, or
  • check in the source code in a repository (git/svn/...) and don't put the "gen" folder in there, then do a check out on another computer.

  • This leads to ADT recreating automatically the "gen" folder during build, this time enabling the "derived" flag, which will trigger the wrong behavior on "clean".

The temporary solution is to:

  • right click "gen"
  • choose "Properties"
  • uncheck "Derived"

as long as the "gen" folder doesn't get deleted you'll be able to clean your project without side effect.

I just checked in a fix to: - never mark the folder as "derived" - during clean, first remove the "derived" flag from "gen" so that it doesn't get deleted in the case of older projects. Patch is visible at:https://review.source.android.com/#change,22410

Friday, May 13, 2011

Bookmarks and Reading for 5/13

Artificial Intelligence
Anyone who is trying to build compelling single player games will be faced with the need to create a compelling second player -- the AI.



IDE vs. Command Line
For those of us who are building in Eclipse for our Android projects, there is another way if you are willing to work at it.



Thursday, May 12, 2011

Why the HTML5 vs. Flash Debate Is Already Over

This is a battle of one vs. many.

Adobe vs. Google/Apple/Microsoft/Opera

JavaScript and HTML5 cannot help but win because they have numbers.

Maybe not browser numbers yet -- but Adobe doesn't even make a browser.