Cogitas Blog:
Google Android,
Common Lisp,
programming
and web design.

How to reset canvas in HTML5

Filed under: web — Tags: , — August 24, 2010

The excellent “Dive Into HTML5″ online tutorial by Mark Pilgrim mentions that to reset a canvas (= clear all its contents), all you need to do is set its width. It even says that you can set the width to be the same as the current width and gives the example below
(more…)

HTML5 sample code for drag ‘n’ drop and many more features

Filed under: programming languages — Tags: , , — August 13, 2010

If you are the type of programmer who learns by reading code and hacking it, head over to HTML5 Studio, a new area on Google’s HTML5 website with sample code provided for Geolocation, Columns, Drag & Drop features and many more.
I quote from the site

Peek around, look under the covers at the source, and feel free to reuse the code in your own applications and sites.

How to create a basic Custom View in Google Android

Filed under: google android — Tags: , , — May 29, 2010

Google Android comes with many view widgets like Lists, Grids, Tabs and so on, but sometimes, you need your own Custom View. Using an example of a view that shows a list of images next to each other, here’s the steps to follow to start you off with your Custom View…

(Apologies for the poor layout of the code, it seems that I need to tweak the theme. This is the first time I am using the code tag and it’s not looking great :-( )

1. Create a class that extends View. In our example, let’s call it CustomView.

2. Create your constructor as below (this is the constructor to use if you load your View via xml).

public CustomView(Context context, AttributeSet attrs){
super(context, attrs);
}

(more…)