Saturday, September 19, 2009

Drupal - Pathauto Module

Hmm.. so u ppl are back... thank god u are :) , now I have some visits...
Without wasting any time, lets start..This time, vll learn pathauto module..So as always, lets begin by asking "WHY"....

Why are we learning this module?
You might have noticed, when you create a page or a story, it is allocated a URL automatically which by default is node/1 or node/2 and so on.. When your website is live, u obvioulsy wouldn't want to have such un-meaningful URLs. It looks more meaningful, if the URLs contain the type of information that the page displays.
So it time to add some meaning to our URLs..

Here we go now ...

1. So as described in my previous posts, u need to download this DHTML module( just goto drupal.org, click on modules do a search with DHTML menu), unzip it and save it in C:\wamp\www\drupal\sites\all\modules.
2. Make sure that you download the correct version.
3. Once you have downloaded it, start the WAMP server and go to http://localhost/drupal .
4. Now login into your account.
5. Goto Administer- Site Building - Module.
6. Click on URL aliases under Path heading.
7. Click on Add Alias.
8. On Existing Alias path, give the automatically generated path( node/1 ..)
9. On Path Alias, give a meaningful name to be associated with a particular page.
10. Click on Create new Alias and BINGO... there u go..

Thats it for now, keep giving some meaningful names to your pages or polls or wtever... I'll be back with some other important modules...

Happy naming :)....


Wednesday, September 16, 2009

Drupal - DHTML Menu Module

This is the simplest module that ive come across during my course fo learning Drupal.

Why are we learning this module?
Thats the first question I believe you shud ask yourself...In case uve not asked yourselves :) , lemme answer it since I raised it at the first place.. :)
Oh k.. If youve explored or played with drupal, you would have noticed that when you click on the parent menu, a new page opens.This increases the number of pages t be opened and makes the user wait. By using DHTML Menu, the sub menu opens up below the parent item and without opening or refreshing the current page.

Here we go, as always :)

1. So as described in my previous posts, u need to download this DHTML module( just goto drupal.org, click on modules do a search with DHTML menu), unzip it and save it in C:\wamp\www\drupal\sites\all\modules.
2. Make sure that you download the correct version.
3. Once you have downloaded it, start the WAMP server and go to http://localhost/drupal .
4. Now login into your account.
5. Goto Administer- Site Building - Module.
6. Check DHTML Menu and click on save configuration
7. Now again goto Administer- Site Configuration(Click on By Module on the top) - DHTML Menu.
8. Now you can check animate sliding effect and decide which menu you want to have DHTML effect.
9. Now keep playing with the options that you see and try to get the effect which suits your needs.

Ill come up with more modules in my next post...


Tuesday, September 15, 2009

Drupal Themes - Configuration

Oh k.. So now we know hot to install and enable themes and modules..
Lets start with the configuration of themes... Before I move ahead, let me tell you that drupal is more like a game.. By this I dont mean that its a child's play, its a kinda thing that the more you explore and play with it, the more you learn....
Let me explain some of the things realted to theme settings.
So lets hit it...
1.Goto Administer-Site Building-Themes.
2.Click on the configure link on the theme that is checked.

Ill discuss now some common things that everybody wants on their page.

Page Elements:These are the elements like logo, site names, slogon... basically self explanatory.
If you dont want to use the default logo, you can upload any other image from your computer.

Breadcrumbs: You would have often seen in websites the hierarchy of the page ie you move from home to careers to contact us etc.
So you can enable breadcrumbs to display your traversal like Home-Careers-Contact Us.
Woah.. m already feeling sleepy... explaining this stuff is boring.. it doesn't deserves and explanation.. I don't know why I wrote this post :) .. You can certainly skip it...

In my next post,Ill explain more about modules.. Yes the commonly used modules which you would be asked in interviews i guess... So pay attention.. No sleeping next time.... Good nite... :)

Monday, September 14, 2009

Installing Themes in Drupal

When we install drupal, there are a lot of themes that come with it. But there are a lot of themes freely available on drupal website. Download any of them in case you sont like the themes that come bundled with drupal.
So, lets get started...

1.Goto drupal.org and download the theme of your choice which comes as a tar.gz file.
2. Unzip the file.
3. Create a folder called themes in C:\wamp\www\drupal\sites\all\
4. Thats it.
5. Now on your drupal menu, goto Administer- Site Buliding.
6. Scroll down the page to see whether your theme name appears or not.
7. Check the box to use the theme.

In my next pos, Ill discuss about the configuration of themes according to your style...

Installing Modules in Drupal

In my previous posts, Ive explained about the installation and configuration of Drupal and WAMP.
Now, lets hit it...
When we install drupal, there are a lot of modules that come with it. But to use the complete power of drupal, we must use the freely available modules on drupal.org.
Here we go...

1.Goto drupal.org and download the module of your choice which comes as a tar.gz file.
2.Unzip the file.
3. Create a folder called modules in C:\wamp\www\drupal\sites\all\
4. Thats it.
5. Now on your drupal menu, goto Administer- Site Buliding.
6. Scroll down the page to see whether your module name appears or not.
7. Check the box to enable the module.

In my next post Ill write about the installation of themes.

Monday, September 7, 2009

Starting WAMP

In this post, Im gonna discuss about the WAMP issue which I faced when I got my hands on it. In the previous posts, Ive described the WAMP and drupal installation, configuration etc.
But after doing all this, when i restarted my computer and double clicked on WAMP, I wasn't able to open the http://localhost/drupal. I checked out services.msc, and I was amazed that inspite of double clicking on WAMP, there was no entry for wampmysqld and wampapache. WTF ...

So I re-installed everything and faced the same problem again on restarting my computer.
I decided to google it and found that WAMP has come issues with Skype , but I had no skype on my computer.
So, I disabled all the firewalls and anti virus on my system, started computer in safe mode with networking, checked ports and what not... Huff... I got tired of searching so I thot of trying it my way...And I did it finally......
So here it goes:

Starting WAMP

1. Double click on wamp. You'll see and icon for WAMP where the time appears on Win XP.
2.Click on the WAMP icon.Goto APACHE- Services- Install Service. A command window opens up, hit enter and it'll be gone.
3.Click on the WAMP icon.Goto MySQL-Service-Install Service.
4. Now goto APACHE- Services-Start/Resume Service.
5. Now goto MySQL- Services-Start/Resume Service.

BINGO !!! Its done now.. Now everythings gonna work. You can check services.msc and ull see wampmysqld and wampapache...

The steps look damn easy but they blow the mind of someone jus starting wid it...

WAMP and Drupal - Installation

Now lets start with the WAMP installation.

Installing WAMP is a child's play. Just do a couple of nexts in the installation wizard and ure on.

Setting up drupal

1. After you download drupal form drupal.org, unzip the file and rename the folder as drupal. After this, paste this folder in C:\wamp\www. ( Assuming your WAMP resides in C:\)
2.Now go to C:\wamp\www\drupal\sites\default and rename the file default.settings.php as settings.php.
3. Now start your wamp by double clicking. The WAMP icon appears at the place where you see the time on Windows XP.
4. Click on WAMP and click on phpMyAdmin.
5. Now on http://localhost/phpmyadmin/ page in your browser, give a database name and click on create.
6. Now type http://localhost/ on the address bar of your browser and just so a couple of next. After performing all the steps, you have drupal installed on your computer.

Ill write more about using drupal in my next post.

Introduction to Drupal

Ok guyz... Its been long since Ive written ( or shud I say its been long since Ive learnt somthing) on my blog. So, as they say, Im back with a bang and this time...Its DRUPAL...I recently got a chance to learn it (thanks to my friends) so thot i shud share it...

What is Drupal ?
Well, drupal is an open source CMS ( Content Management System). This means that using Drupal, we can build and manage websites in no time. Just download Drupal and use the freely available modules available on drupal.org. No need to learn HTML,DHTML and to scratch your head on css.

How to start?
Ok, to start with, we need to download WAMP (Windows, Apache, MySQL and PHP).All these four things come bundled in WAMP. So visit http://www.brothersoft.com/wampserver-70590.html and download WAMP 2.0 h.

Next, you need to download Drupal ver 6.x from http://www.drupal.org .

In my next post, Ill teach u how to install these.

Saturday, July 4, 2009

SELECT COUNT(*) v/s SELECT COUNT(1) - FASTER??

I was writing a PL/SQL code one day using select count(*) from Table_name when somebody told me that select count(1) is better and faster. Although, he couldn't tell me the reason but he gave me a fact. So i jumped upon to search the reason.

Select count(*) uses a TABLE SCAN ie all the rows are looked upon one by one based on your WHERE CLAUSE whereas select count(1) uses an INDEX SCAN which has better performance as the scan is based on indexes.

TABLE scan is faster if the table is small.

Saturday, June 27, 2009

PL/SQL Developer- Setting Path in Preferences

What is PL/SQL Developer?
Well, PL/SQL developer is like an IDE for ORACLE. You can connect PL/SQL Developer to ORACLE database and then create and compile procedures and function, create users, views,tables and much more that you do with ORACLE.

Setting the path
When you use it for the first time, you need to set the path in the Preferences. Set the following paths:
Oracle Home: This path contains the path of your database:
For example - C:\oracle\product\10.2.0\db_1
OCI Library: This contains the path of the file oci.dll in the BIN directory.
C:\oracle\product\10.2.0\db_1\BIN\oci.dll

Reopen PL/SQL developer so that the changes take place effectively.
Thats it, happy developing !!!

Friday, June 26, 2009

ORACLE- Tablespaces and datafiles





Tablespaces:
It is a unit of storage where ur database is kept. There may be one or more tablespaces depending on the size of ur database.
Datafiles:
Each tablespace comprises of one or more datafiles.To increase tablespace, you need to add datafiles to the tablespace.

Types of tablespaces:
---- SYSTEM tablespace contains the data dictionary.
----USERS tablespace is used to store user data(table, indexes etc)
----The SYSAUX tablespace provides a single location for all non-essential database metadata. In the past the schema objects to support many database features were located in the SYSTEM tablespace. These have now been moved to the SYSAUX tablespace. As a result the SYSTEM tablespace is less cluttered and suffers less contention.
----TEMPORARY tablespaces are used to manage space for database sort operations and for storing global temporary tables. For example, if you join two large tables, and Oracle cannot do the sort in memory space will be allocated in a temporary tablespace for doing the sort operation
----UNDO tablespaces are special tablespaces used solely for storing undo information. You cannot create any other segment types (for example, tables or indexes) in undo tablespaces.

ORACLE- Import and Export

Lets say u have a huge database created in Machine A. Now you want a replica of the database in machine B at a different location.. What r u gonna do? Copy the SQL CREATE-INSERT statements, then execute these. What if u miss out on an insert statement???
Well, to perform these tasks, ORACLE provides import and export commands.

If you want to create a replica of ur database, create a dump(.dmp) using exp command
exp file=(location where dump is to be created) Log=(location where log is to be created) owner=(user whose dump is being exported)

Now to import this dump into a new user:

imp file=(location where dump is kept) fromuser=(user whose dump is being exported) touser=(user where dump is being imported)

There u go... The database gets created successfully.

Saturday, June 20, 2009

Checking 32-bit/64-bit ORACLE

Have u ever installed 32-bit ORACLE on a 64-bit system by mistake nd u never realized it. Well, use this command to know whether 32 bit or 64 bit ORACLE is installed on ur system.

SELECT DISTINCT ADDRESS FROM v$sql where rownum<2;

If the address is 16 characters long like 00000000345BA23E, uve got 64 bit oracle on ur system.

But if the address is 8 characters long like 098765EA, then its 32 bit ORACLE.

Tuesday, June 16, 2009

ORACLE Installation

Have you ever tried to install ORACLE on Linux. Well, its a bit of struggle if you don't know the correct settings.Believe me, I had a hard time installing ORACLE for the first time on Linux. But I think, you guys shouldn't waste time. So, here we go:

First of all you need to have the required packages and RPMs. You can find these easily from manual.
After installing all the packages, begin with the following steps:

Step 1: Add/Modify the following lines to /etc/sysctl.conf

kernel.shmmni =4096
kernel.sem=250 32000 100 128
fs.file_max=65536
net.ip_local_port_range= 1024 65000
net.core.rmem_default=1048576
net.core.rmem_max=1048576
net.core.wmem_default=262144
net.core.wmem_max=262144
net.ipv4.tcp_wmem=262144 262144 262144
net.ipv4.tcp_rmem=4194304 4194304 4194304

Step 2: #sysctl -p
So that changes take place effectively.

Step 3: Create oracle user and groups
#groupadd oinstall
#groupadd dba
#useradd -g oinstall -a dba oracle -- This server as username.
#passwd

Step 4: Create required directories
#mkdir -p /home/oracle
#
chown -R oracle:oinstall /home/oracle
#chmod -R 755 /home/oracle

Step 5: Add the following lines to /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16348
oracle soft nofile 1024
oracle hard nofile 65536

Step 6: Add the following lines to /etc/passwd/login
session required pam_limits.so

Step 7: Add following to /etc/profile
if[$USER="oracle"]; then
ulimit -u 16384
ulimit -n 65536

Step 8: Add/modify /home/oracle/.bash_profile
umask 022
export ORACLE_BASE=/home/oracle
export ORACLE_SID=orcl
export ORACLE_HOME= $ORACLE_HOME/oracle/product/10.2.0/db_1
LD_LIBRARY_PATH=$ORACLE_HOME/bin:$PATH
export PATH

Step 9:
xhost +
xclock

Step 10: Run the GUI Installer
./runInstaller

There you go, now just do a couple of nexts and ull have oracle installed... CHEERS :)

Wednesday, May 27, 2009

ORACLE - Use of tnsnames.ora and listener.ora files

LISTENER.ORA
This file contains configuration for the server side.It contains details like on which port, which protocol etc the server should listen for connection requests from clients. This file is found in ORACLE_HOME/network/admin directory.

TNSNAMES.ORA
The file contains configuration for client side. It can be found in the ORACLE_HOME/network/admin . This file will also be present on the server if client is also on the same machine as server. This file needs to be configured for all clients with the IP address and port of the server so that clients can communicate with the server.

I will come up with the configuration of these files shortly for using a gateway.

Tuesday, May 26, 2009

OTG - Oracle Transparent Gateway

OTG or Oracle Transparent Gateway is a tool used to communicate with non-Oracle products (may be other databases like DB2) and technologies. Using OTG, we can access data in remote DB2 using Oracle's PL/SQL syntax. OTG has DRDA gateway which connects with DB2. If you want to connect to other databases like Sybase n all, you can use other gateways.

To use a gateway, we need to first install it( quite obvious). After installation, we need to configure it which is a tedious task even if we try to do it by reading manuals.( I've been working on it for 3 days, still no progress).

Well, thats all i know about it but I will surely write about the configuration in my next post. So wish me luck :).

Friday, May 22, 2009

PL/SQL Wrapper

Have you ever tried to see the contents of the object file in C ?
If not, then let me tell you that it contains all unreadable characters ie, given the object code, nobody can generate the C code from it.
If you want a similar kind of protection in PL/SQL code, you need to use wrap command. In this way, you can protect your source code. You can now distribute your wrapped code without the fear of it being copied. The PL/SQL compiler recognizes and loads wrapped code automatically.


Using PL/SQL Wrapper

wrap iname=plsqlsource.sql oname=plsqlwrapcode.plb

where the extension plb means PL/SQL binary.

Saturday, May 16, 2009

ORACLE 8i, 11g - What is "i" and "g"

Meaning of "i" and "g"

Well "g" in Oracle 10g and onwards indicates grid computing. Grid computing means clubbing of several computers, by means of a network, where they work on a single problem at the same time. It enables resource sharing for multiple applications thus giving advantages like flexibility,low cost, efficiency, performance, scalability etc.

The "i" in Oracle 8i,9i indicates support for the Internet with built-in Java Virtual Machine (JVM). With a JVM (Java interpreter) built into the DBMS, triggers and stored procedures can be written and executed in Java . It thus enables Internet developers to write applications as well as procedures in Java.

Friday, May 15, 2009

ORACLE DATA TYPES

Lets discuss three data types CHAR, VARCHAR and VARCHAR2 and understand the differences between them. This is also one of the frequently asked questions in interviews.

CHAR
It is used for storing fixed length character strings. For example FLAGS in tables which contain Y or N for YES or NO respectively.
NAME CHAR(50);
When we declare such a type for name which contains variable no of characters, it results in wastage of lot of space.
NAME := 'MANIK' fills 5 places rest of the places will be padded with spaces.
So, its not a good idea to use this type for variable length strings.
NOTE: When we don't specify a size with CHAR, it defaults to one.


VARCHAR
Its not used generally, I learnt from internet that it is kept for furture use, otherwise it behaves same as VARCHAR2 as discussed next

VARCHAR2
It is used for storing variable length strings. In Oracle 10g, a VARCHAR2 column may be up to 4000 bytes in a table and it may be up to 32767 bytes in a PL/SQL program.

NAME VARCHAR2(50) := 'MANIK';
This does not leads to wastage of space. Only 5 places are occupied.

Saturday, April 18, 2009

Oracle Storage and High water Mark

Lets understand how data is stored in Oracle ...

Each table in oracle is made up of a number of extents and each extent is made up of a number of blocks. 
ie Table = x number of extents
  extent = y number of blocks
 segment = set of extents

A word about high water mark
HWM: Its divides segments into used and unused 
Blocks below HWM contain data and those beyond HWM are free.

DATA
_____________________________HWM__________________________
FREE BLOCKS

Resetting HWM:
Lets say that you fill your table with 4 million records. As a result, you fill in several extents. Now lets delete half of these records. Now your table still has those extents allocated but lots of them are empty. When we run a query on this table with a WHERE clause, all the extents are scanned including the empty ones which is obviously a performance overhead.
So to reset your HWM, use this statement ALTER TABLE MYTABLE MOVE TABLESPACE USERS.

Note: When data is inserted , HWM is automatically adusted. 
           When data is deleted, HWM is not adjusted automatically.

DELETE * v/s TRUNCATE
TRUNCATE resets the HWM, DELETE doesn't.

Tuesday, April 14, 2009

Global Temporary Tables

CREATE GLOBAL TEMPORARY TABLE was introduced in Oracle 8i.The CREATE GLOBAL TEMPORARY TABLE command creates a temporary table which can be transaction specific or session specific. For transaction-specific temporary tables, data exists for the duration of the transaction while for session-specific temporary tables, data exists for the duration of the session. Data in a temporary table is private to the session. Each session can only see and modify its own data.

Transaction specific table:
CREATE GLOBAL TEMPORARY TABLE T_TEMP (
column1 NUMBER,
column2 NUMBER
) ON COMMIT DELETE ROWS;

Session Specific table

CREATE GLOBAL TEMPORARY TABLE T_TEMP
(
column1 NUMBER,
column2 NUMBER
) ON COMMIT PRESERVE ROWS;
Features:

Data in temporary tables is automatically deleted at the end of the database session,, no matter what happens.
If the TRUNCATE statement is carried out on a temporary table, only the session specific data is truncated. Other sessions are not affectd.
We can perform DDL commands like ALTER TABLE, DROP TABLE etc only when no session is currently bound to it. A session gets bound to a temporary table when an INSERT is performed on it. The session gets unbound by a TRUNCATE, at session termination, or by doing a COMMIT or ABORT for a transaction-specific temporary table.

Friday, April 10, 2009

ORACLE - SPOOL COMMAND

What is SPOOL ?
Spool Command in ORACLE is used to transfer data from oracle tables into other files.

How to SPOOL from ORACLE in CSV format ??

Set echo off;
Set define Off;
Set feedback Off;
Set serveroutput On;
SET PAGESIZE 0
SET LINESIZE 1000
Spool c:\file.csv

SELECT EMPNAME||','||EMPID||','||EMPSAL FROM EMPLOYEE;

Spool Off;
Set define On;
Set feedback On;

Thursday, April 9, 2009

Fiddling with DATES

1. Selecting current date
SELECT SYSDATE FROM DUAL;

2. Adds one day to current date
SELECT SYSDATE+1 FROM DUAL;

3. Adding months
SELECT ADD_MONTHS(SYSDATE,2) FROM DUAL;

4. TRUNC
It truncates the time part from the date TRUNC(SYSDATE).

5. MONTHS_BETWEEN( date1, date2 )
Gives the number of months between two dates.

Wednesday, April 8, 2009

EXECUTE IMMEDIATE

EXECUTE IMMEDIATE VS DBMS_SQL
EXECUTE IMMEDIATE provides better performance than DBMS_SQL.
EXECUTE IMMEDIATE" was added in Oracle 9i. DBMS_SQL package was used to execute
dynamic sql queries in earlier versions.

Using EXECUTE IMMEDIATE

1.
begin
execute immediate 'SQL Statement';
end;

2.To retrieve value from a dynamic statement
declare
var varchar2(20);
begin
execute immediate 'select count(*) from employee'
into var;
dbms_output.put_line(
var);
end;

In case of static sql statement we use select count(*) into var from employee;

3.EXECUTE IMMEDIATE doesn't commits a DML transaction.An explicit commit should be done.

4.Using variables with EXECUTE IMMEDIATE

x number := 10000;
execute immediate 'select count(*) from employee where salary > '||x into var;

Friday, March 27, 2009

Display text using file in GTK View

Here's a simple code to extract data from a text file and display it in a View.

FILE *fp; // FILE pointer
char buff[100]; // To hold text extracted from FILE

GtkWidget *det ;
GtkWidget *view1=NULL ; // View used to display text (initialized to NULL)

view1=lookup_widget(GTK_WIDGET(widget),"view_tm");

/* "view_tm" is the view name given using GLADE
widget (GtkWidget *) -> This pointer is passed automatically when an event takes place */

fp=fopen("file_to_display.txt","r");

while(!feof(fp))
{
fgets(buff,60,fp);

det=gtk_list_item_new_with_label (buff);

gtk_container_add (GTK_CONTAINER (view1), det);

}
/* gtk_list_item_new_with_label ()
Creates a new GtkListItem with a child label containing the given string.
label :
the string to use for the child label.
Returns :
a new GtkListItem with a child GtkLabel with the text set to label.
*/


gtk_widget_show(det);
fclose(fp);


}

Friday, February 6, 2009

Glade Interface and GTK

A word about Glade Interface Designer?
Well !! If you want to create Visual C++ like graphical application , you can use Glade. It comes as default installation with Fedora 6,7 ( i dun know abt other versions n distros). All you need to do is select and drag a couple of widgets (see previous post to know about widgets) and choose a layout. It can be used with any desktop environment in Linux, as long as the gtk+ and/or gnome libraries are installed. Glade can be downloaded from glade.gnome.org.

Other facts :

  • Glade develops the GUI and associated code
  • It creates empty callbacks and signal handlers to link the frontend GUI with the backend of the application
  • Glade doesn't develop the 'backend' of your application

Glade is not a complete IDE, in other words it does not include a compiler, editor or debugger. It is used in conjunction with these, for example with gvim as the editor, gcc as the compiler and gdb as the debugger. There are several IDEs for Linux that work with, or attempt to work with Glade. Anjuta is one.

GTK + :
After creating the interface, we need to program it for responses received from users, this part is done by GTK- GNU ToolKit. The GTK+ library is responsible for drawing the windows, dialogue boxes and buttons in the GIMP, Pidgin and hundreds of other programs.

Friday, January 30, 2009

Fiddling with widgets

How to create a simple android application using widgets?
In this post, I'll give you the code for creating a simple Welcome Application using widgets. After you create a project ( File - New -Project-Android Project), lets say Welcome, you'll get a file called Welcome.java. Replace the following code with the existing code:

package com.android.hello;

import android.app.Activity;
import android.os.Bundle;
import android.widget.*;
import android.view.View;
import android.content.Intent;


public class Hello extends Activity {

/** Called when the activity is first created. */
TextView a,b,c;
Button d;
EditText e;
String sname;
@Override
public void onCreate(Bundle savedInstanceState) {
a=(TextView)findViewById(R.id.Name);
b=(TextView)findViewById(R.id.wel);
c=(TextView)findViewById(R.id.msg);
d=(Button)findViewById(R.id.sub);
e=(EditText)findViewById(R.id.nm);
e.setText(" ");
d.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
sname=e.getText().toString();
c.setText(sname);

}
});

super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}


Main.xml


android:id="@+id/widget0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
android:id="@+id/sub"
android:layout_width="127px"
android:layout_height="wrap_content"
android:text="Submit"
android:layout_x="91px"
android:layout_y="116px"
>

android:id="@+id/Name"
android:layout_width="121px"
android:layout_height="21px"
android:text="Enter your name"
android:layout_x="23px"
android:layout_y="46px"
>

android:id="@+id/wel"
android:layout_width="86px"
android:layout_height="28px"
android:text="Welcome"
android:layout_x="37px"
android:layout_y="223px"
>

android:id="@+id/nm"
android:layout_width="148px"
android:layout_height="31px"
android:textSize="18sp"
android:layout_x="144px"
android:layout_y="42px"
>

android:id="@+id/msg"
android:layout_width="133px"
android:layout_height="22px"
android:layout_x="114px"
android:layout_y="224px"
>



Welcome Application:
Well, this is a simple application. All it does is that it inputs your name and when you hit the submit button, it displays Welcome on the same screen. This is just a small example to demonstrate the working of widgets.


Code Explanation:

In the xml code for a widget, for eg android:id="@+id/something" , the text after slash("/") gives the name of your widget. We will use this reference in Welcome.java.

Welcome.java

The first step is to create an object for each widget.

We now need to initialize each of these objects with the widget name given in main.xml. This is done by findViewById(R.id.something). You must be wondering where this R came from. Well, check out the file R.java, you will see the class name as R. This file is auto generated with some kind of values like 0x7f020000 (hexa values), do not make changes in this file.

We now need to set a listener whcih will respond when the submit button is clicked. This is done by onClickListener(), I have taken the text from the text field and set it on the textview. Thats it, quite simple, isn't it!!!

Now jus run it as Android application in Run Menu.. Wait for a couple of minutes since the emulator takes a lot of time when it runs for the first time.....

Sunday, January 25, 2009

Android-DroidDraw


A word about widgets:
Well, all your text boxes, radio buttons, check boxes etc are called widgets. Believe me, you don't need to know anything else :) ...

Designing a Layout: DroidDraw
Some of you may think that you need to know xml to design a layout of your application. Theres a good news for you, tools like DroidDraw let you design layouts without any knowledge about xml.
Heres how:
1. Go to http://www.droiddraw.org/ and download DroidDraw for free.
2. Now open it, and choose the layout(I prefer absolte layout).
3. Click on the Widgets tab on the right side and drag the widget to be inserted.
4. Click on the properties tab and type a meaningful name for the widget.
5. In the Id field, type another name.This is the name that you will choose for reference in your program.
6. Click on Generate, this generates the xml code for the layout.

Where do I use the xml code generated?
You need to replace this generated code with your main.xml (in Projectname/res/layout).


Friday, January 23, 2009

Configuring Eclipse for Android Project

Configuring Eclipse for Andorid Project
After updating the eclipse with the steps in the previous post, you need to configure eclipse with android sdk path. Here are the steps:
  • Go to the android Windows > Preferences menu. Eclipse Preference window will be opened.
  • Select Android from the left hand size menu.
  • Click on the Browse button and select the location of the SDK.
  • Click Apply and then Ok.

Saturday, January 10, 2009

Android Installation

What is Android ?
Android is a software stack for mobile devices that includes an operating system, middleware and key applications.Using Android, you can create applications,like you can do using J2ME.

Installing Android on Windows XP
Its very easy to install android after you read this tutorial.Just follow the steps:
1. Go to http://code.google.com/android/ and download the Android SDK.This contains Android emulator, documentation and sample codes.
2. Go to http://www.eclipse.org/downloads/ and download Eclipse IDE using which you will write your applications.
3. You now need to download ADT, which is a plugin.It needs to be configured with Eclipse so that you can create applications.
4. Open your Eclipse IDE, Click on Help-Software Updates-Available Sofwares (tab)-Add Site.
5. On the location box write, https://dl-ssl.google.com/android/eclipse/ and click OK.
6. You will now get a check box, expand it and check all the items.Click on the Install button.
7. After this, click on a couple of next and finish and wait until it gets downloaded form internet.
8. Right click on My Computer-Properties-Advanced(tab)-Environment Variables-Edit the variable Path and give the location of the tools folder in the unzipped Android SDK folder.
9. Restart your computer.
10. Open Eclipse, Click on File-New-Android Project..

Congratulations, you have now successfully installed Android..