How To Fix The AnimationDrawable Does Not Work In Android Problem
Posted by blogmeister on
July 1, 2011
There is a big chance that you did this within the onCreate() method of the Activity class and you wondered why if with the click of the button, it works.
I read a post from the Stack Overflow forum that the start() method called on the AnimationDrawable cannot be called during the onCreate() method of your Activity because the AnimationDrawable is not yet fully attached to the window.
A good suggestion by user will is to create an inner class where you trigger the start() method of the AnimationDrawable. Try the sample inner class below in your class. It should work.
|
1 2 3 4 5 |
class AnimationStart implements Runnable { public void run() { animationDrawableObject.start(); } } |
Find Words That Start With Slash Using Regex In Java
Posted by blogmeister on
September 30, 2010
The method below matches all words that starts with a slash and no other slash should be found within the String. Using regex, I used a positive look behind approach that whenever a slash character is found, it should check if the previous character is a space character while the whole word should also be followed by a space character as well.
This way, the regex pattern ensures that the first chracter should be a slash and any characters following it are accepted such that there should be a space character at the end.
|
1 2 3 4 5 6 7 8 9 10 11 |
public static void findWordsThatStartWithSlash(String content) { String str = null; if (content.startsWith("/")) str = " " + content; else str = content; Pattern slash = Pattern.compile("(?<=[\\s])/\\w+\\s"); Matcher m = slash.matcher(str); while (m.find()) { System.out.println("MATCH: [" + m.group() + "]"); } |
The regex does have a little limitation. What if the very first character of the String is a slash? Then it would not match that word because there is no previous space character before it. The only workaround for this one was to check if the String starts with a slash and if so, manually add a space character at the very first index of the String.
Found this useful? Donations appreciated to help keep this blog alive.







