Thursday, August 25, 2011

Calling Android Resources Dynamically by passing String names

Suppose you have 3 types of resources (String, Drawable and Raw) for 50 kinds of animals like the following:

And suppose you want just 3 resources (String, Drawable and Raw) to be loaded for the ONE specific animal which the user will choose ONE at a time - that's gonna be like 50 if-else conditional statements with 3 resource definitions each = 150 lines of code.

With the following example, you can reduce it down to just about 36 lines of code to do exactly that.

Wednesday, August 24, 2011

Calling Java methods dynamically by passing a String of the method name

Imagine you have 99 distinct methods:
  • method1()
  • method2()
  • method3()
  • method4()
  • ...
  • ...
  • ...
  • method99()
and each of these methods are distinct methods with distinct functionality which will be executed for the 99 distinct return values of your getID() method.

So typically you would have to write 99 if-else condition statements. What if you could simply do the same thing in one line instead of defining 99 if-else condition statements.
call_method ("method" + getID());
The following code snippet is a simple tutorial of how to use STRING parameters for calling methods dynamically in java.

Friday, August 19, 2011

Enable Icons, "Open in Terminal", "Open as Administrator" in ubuntu context menus

This article describes how to add some useful extensions to your context menu on Linux ubuntu...

Usually in ubuntu, you don't get to see "icons in the context menu items" like the following.
To enable this in the context menu like above, execute the following in terminal:
gconftool-2 --type bool --set /desktop/gnome/interface/menus_have_icons true

Monday, August 1, 2011

10 for women to be safe in the society

and this landed into my inbox from my dear friend 
Tasfia Rahman

In daylight hours, refresh yourself

of these things to do in an emergency situation...

This is for you, and for you to share with your wife,

your children, & everyone you know.

After reading these 9 crucial tips,

forward them to someone you care about.

It never hurts to be careful in this crazy world we live in.

1.Tip from Tae Kwon Do :

The elbowis the strongest point

on your body.

If you are close enough to use it, do!

2. Learned this from a tourist guide.

If a robber asks for your wallet and/or purse,


Toss it away from you....

Chances are that he is more interested

in your wallet and/or purse than you,

and he will go for the wallet/purse.