Warning: Use of undefined constant _FILE_ - assumed '_FILE_' (this will throw an Error in a future version of PHP) in /home/bolyarco/www-ikratko/ogrelab/wp-content/plugins/ad-blocker-stats-vip/ad-blocker-stats-vip.php on line 13

Archive for the ‘Android’ Category

Identifying the view selected in a ContextMenu (in onContextItemSelected() method)

2011-07-12   

Have you ever needed to popup a ContextMenu by longclicking on some of the UI element (different than item in ListView) for example an ImageView instance? At first glance it seems that this can be acomplished quite easy but in reality there is one big problem: you have only one onContextItemSelected() method in your activity that is called every time a context menu item is selected no matter which View requested the ContextMenu via openContextMenu(). This situation is not a problem if just one View is poping a ContextMenu but sometimes you need to popup ContextMenu from several different views. Let me show an example from a real app:

In this layout I have 4 ImageViews. img1 is called "primary" and all other "secondary". By specification I had to (more…)

Пуснах версия 2.0 на "МОЕТО ТОТО 2" (Android app)

2011-02-22   

Вчера мисля, че успях да ликвидирам и последния бъг в новата версия на Моето Тото 2 и тя беше публикувана в андроид маркета. Новите неща включват:

  • възможност за записване на генерираните комбинации;
  • възможност за въвеждане и записване на собствени комбинации (чрез доста удобен интерфейс IMNSHO :-) )

Връзки за сваляне:

Moeto Toto 2

За версия 3.0 очаквайте функционалност за сваляне на числата от тиражите по интернет + автоматична проверка за печалби.

Custom color buttons for Android (9-patch images + example project)

2011-02-15   

On several occasions I had to create simple buttons that use different background color than the default gray. I've tried to google for already cooked solution but quite surprisingly -- I was unable to find one that suits me so I had to create solution by my self (not really, I just combined other solutions in one easy to use packaged solution).

There are three approaches:

1. First approach (bad) -- just set the background to some color like this

The problems:

a) button does not have rounded edges (and does not fit in the look & feel, i.e. looks alien)

b) does not support changes of the color to indicate focus or pressed state.

2. Second approach (not very good) -- create custom drawable definitions in xml file that use gradients (<gradient>). The problem is that buttons don't look quite the same as default buttons -- edges are not quite with the same roundness, margins and paddings are different. When I first tried to create colored buttons I've tried this approach but after 2-3 hours playing with paddings and roundess I finally gived up.

3. Third approach (the right(eous) one) -- Use different 9-patch images for the different colors.

It works very simple: (more…)