2010년 4월 26일 월요일

From javascript to java, From Java to javascript

 

 

Reference http://www.itcpub.co.kr

Access SDCard

C:\>mksdcard 256M c:\sd.img

C:\>dir c:\sd.img
 C 드라이브의 볼륨에는 이름이 없습니다.
 볼륨 일련 번호: D88A-40A9

 c:\ 디렉터리

2010-04-27  오전 09:49       268,435,456 sd.img
               1개 파일         268,435,456 바이트
               0개 디렉터리  68,453,728,256 바이트 남음

 

 

 

 

 

 

数独




























































































































































































































2010년 4월 21일 수요일

Setting PHPMyAdmin

1) http://www.gilbut.co.kr/book/detailCscenterRead.asp > PHP4 무작정 따라하기 > p4util.zip 다운

 

2) p4util.zip 압축풀고  phpmyadmin.zip 압축풀어서 phpmyadmin 폴더를 C:\Program Files\Apache Group\Apache2\htdocs 안에 복사

 

3) C:\Program Files\Apache Group\Apache2\htdocs\phpmyadmin\config.inc.php 파일을 메모장으로 열고 아래부분 찾아서 아래와 같이 수정

 

$cfgServers[1]['host']          = 'localhost'; // MySQL hostname
$cfgServers[1]['port']          = '';          // MySQL port - leave blank for default port
$cfgServers[1]['socket']        = '';          // Path to the socket - leave blank for default socket
$cfgServers[1]['connect_type']  = 'tcp';       // How to connect to MySQL server ('tcp' or 'socket')
$cfgServers[1]['stduser']       = '';        

$cfgServers[1]['stdpass']       = '';          //   access to the "mysql/user" and "mysql/db" tables)
$cfgServers[1]['auth_type']     = 'config';    

$cfgServers[1]['user']          = 'root';      // MySQL user
$cfgServers[1]['password']      = '1234';  // MySQL password (only needed with 'config' auth)
$cfgServers[1]['only_db']       = '';

 

4) 브라우저 실행후 http://localhost/phpmyadmin/index.php 실행

 

 

Connection PHP to MySql

1) mysql_connect 함수로 MySql 연결

C:\Program Files\Apache Group\Apache2\htdocs\MySqlEx1\connect.php

 

<?
$connect = mysql_connect("localhost","small","password");  
mysql_select_db("company", $connect); 
$result = mysql_query("select * from friend", $connect);

if (!$result) {

echo "거짓! 테이블이 없는데요.";
}else {
echo "참! user 테이블에 모든 데이터를 선택하였습니다.";
}
mysql_close($connect);
?>

 

IE에서 http://localhost/MySqlEx1/connect.php 실행

 

결과 >

참! user 테이블에 모든 데이터를 선택하였습니다.

 

2) mysql_num_rows 함수로 데이터 행의 개수 구하기

C:\Program Files\Apache Group\Apache2\htdocs\MySqlEx1\num_rows.php

 

<?
$connect = mysql_connect("localhost","small","password"); 
mysql_select_db("company", $connect);
$result = mysql_query("select * from friend", $connect);
$num = mysql_num_rows($result);
echo "$num";
mysql_close($connect);
?>

 

결과 >

2

 

3) mysql_fetch_array 함수로 쿼리의 결과를 한 줄 배열로 보여주기

 

C:\Program Files\Apache Group\Apache2\htdocs\MySqlEx1\fetch_array.php

 

<?
$connect = mysql_connect("localhost","small","password");
mysql_select_db("company", $connect);
$result = mysql_query("select * from friend", $connect);
while($row=mysql_fetch_array($result)) {
echo "no : $row[0] | name : $row[1] | tel : $row[2]<br>";
echo "no : $row[no] | name : $row[name] | tel : $row[tel]<br>";
}
mysql_close($connect);
?>

 

결과 >

no : 1 | name : James Kim | tel : 1089971234
no : 1 | name : James Kim | tel : 1089971234
no : 2 | name : Fernando Torres | tel : 1089977777
no : 2 | name : Fernando Torres | tel : 1089977777

MySql Start2

C:\mysql\bin>mysqldump -uroot -p1111 company > company.sql  //  백업

C:\mysql\bin>mysql -uroot -p1111 company < company.sql  // 복구

mysql> use company
Database changed
mysql> show tables
    -> ;
+-------------------+
| Tables_in_company |
+-------------------+
| friend            |
+-------------------+
1 row in set (0.00 sec)

mysql> desc friend;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| no    | int(11)     | YES  |     | NULL    |       |
| name  | varchar(15) | YES  |     | NULL    |       |
| tel   | int(30)     |      |     | 0       |       |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

 

mysql> insert into friend(no,name,tel) values('1','James Kim','01089971234');
Query OK, 1 row affected (0.00 sec)

mysql> select * from friend;
+------+-----------+------------+
| no   | name      | tel        |
+------+-----------+------------+
|    1 | James Kim | 1089971234 |
+------+-----------+------------+
1 row in set (0.00 sec)

 

mysql> insert into friend(no,name,tel) values('2','Steven Gerrard','010-8997-1235');
Query OK, 1 row affected (0.00 sec)

mysql> select * from friend;
+------+----------------+------------+
| no   | name           | tel        |
+------+----------------+------------+
|    1 | James Kim      | 1089971234 |
|    2 | Steven Gerrard |         10 |
+------+----------------+------------+
2 rows in set (0.00 sec)

mysql> delete from friend where no=2;
Query OK, 1 row affected (0.00 sec)

 

mysql> insert into friend(no,name,tel) values('2','Fernando Torres','01089971236');
Query OK, 1 row affected (0.00 sec)

mysql> select * from friend;
+------+-----------------+------------+
| no   | name            | tel        |
+------+-----------------+------------+
|    1 | James Kim       | 1089971234 |
|    2 | Fernando Torres | 1089971236 |
+------+-----------------+------------+
2 rows in set (0.00 sec)

mysql> update friend set tel='1089977777' where no=2;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from friend;
+------+-----------------+------------+
| no   | name            | tel        |
+------+-----------------+------------+
|    1 | James Kim       | 1089971234 |
|    2 | Fernando Torres | 1089977777 |
+------+-----------------+------------+
2 rows in set (0.00 sec)

MySql Start

C:\>cd mysql/bin

 

C:\mysql\bin>mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 3.23.53-max-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

 

mysql> show databases;
+----------+
| Database |
+----------+
| mysql    |
| test     |
+----------+
2 rows in set (0.00 sec)

 

mysql> use mysql;
Database changed


mysql> show tables;
+-----------------+
| Tables_in_mysql |
+-----------------+
| columns_priv    |
| db              |
| func            |
| host            |
| tables_priv     |
| user            |
+-----------------+
6 rows in set (0.00 sec)

 

mysql> select host,user,password from user;
+-----------+------+----------+
| host      | user | password |
+-----------+------+----------+
| localhost | root |          |
| %         | root |          |
| localhost |      |          |
| %         |      |          |
+-----------+------+----------+
4 rows in set (0.02 sec)

 

mysql> update user set password = password('1111') where user='root';
Query OK
, 2 rows affected (0.09 sec)
Rows matched: 2  Changed: 2  Warnings: 0

 

mysql> select host,user,password from user;
+-----------+------+------------------+
| host      | user | password         |
+-----------+------+------------------+
| localhost | root | 45271aba0b765d95 |    <---  지정한 비밀번호를 암호화해서 보여줌.
| %         | root | 45271aba0b765d95 |
| localhost |      |                  |
| %         |      |                  |
+-----------+------+------------------+
4 rows in set (0.00 sec)

 

mysql> quit;
Bye

 

C:\mysql\bin>mysqladmin reload

C:\mysql\bin>mysql -u root -p mysql
Enter password: ****     <--- 위에서 root에 지정했던 비밀번호 입력
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 3.23.53-max-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> GRANT ALL PRIVILEGES ON *.* TO small@localhost IDENTIFIED BY 'password'
    -> WITH GRANT OPTION;
   <--- *.* : 전체 데이터베이스에 접근할 수 있는 권한
Query OK, 0 rows affected (0.00 sec)

 

mysql> select host,user,password from user;
+-----------+-------+------------------+
| host      | user  | password         |
+-----------+-------+------------------+
| localhost | root  | 45271aba0b765d95 |
| %         | root  | 45271aba0b765d95 |
| localhost |       |                  |
| %         |       |                  |
| localhost | small | 5d2e19393cc5ef67 |   <--- 새로운 사용자 추가됨.
+-----------+-------+------------------+
5 rows in set (0.00 sec)

 

mysql> GRANT ALL PRIVILEGES ON company.* TO small@localhost IDENTIFIED BY 'password'
    -> WITH GRANT OPTION;
       <--- company.* : company 데이터베이스에 접근할 수 있는 권한
Query OK, 0 rows affected (0.00 sec)

 

mysql> create database JPControls;
Query OK, 1 row affected (0.08 sec)

 

mysql> show databases;
+------------+
| Database   |
+------------+
| jpcontrols |
| mysql      |
| test       |
+------------+
3 rows in set (0.00 sec)

 

mysql> drop database jpcontrols;
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+----------+
| Database |
+----------+
| mysql    |
| test     |
+----------+
2 rows in set (0.00 sec)

 

mysql> create database company;
Query OK, 1 row affected (0.00 sec)

mysql> show databases;
+----------+
| Database |
+----------+
| company  |
| mysql    |
| test     |
+----------+
3 rows in set (0.00 sec)

mysql> GRANT ALL ON company.* TO small;
Query OK, 0 rows affected (0.00 sec)

 

mysql> create table friend (
    -> no int,
    -> name char(15),
    -> phone int(20)
    -> );
Query OK, 0 rows affected (0.01 sec)

 

mysql> show tables;
+-----------------+
| Tables_in_mysql |
+-----------------+
| columns_priv    |
| db              |
| friend          |
| func            |
| host            |
| tables_priv     |
| user            |
+-----------------+
7 rows in set (0.00 sec)

 

mysql> drop table friend;
Query OK, 0 rows affected (0.00 sec)

 

mysql> use company
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql> create table friend (
    -> no int,
    -> name char(15),
    -> phone int(20)
    -> );
Query OK, 0 rows affected (0.00 sec

mysql> show tables;
+-------------------+
| Tables_in_company |
+-------------------+
| friend            |
+-------------------+
1 row in set (0.00 sec)

 

mysql> desc friend;
+-------+----------+------+-----+---------+-------+
| Field | Type     | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| no    | int(11)  | YES  |     | NULL    |       |
| name  | char(15) | YES  |     | NULL    |       |
| phone | int(20)  | YES  |     | NULL    |       |
+-------+----------+------+-----+---------+-------+
3 rows in set (0.00 sec)

mysql> ALTER TABLE friend ADD email varchar(40);
Query OK, 0 rows affected (0.05 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc friend;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| no    | int(11)     | YES  |     | NULL    |       |
| name  | varchar(15) | YES  |     | NULL    |       |
| phone | int(20)     | YES  |     | NULL    |       |
| email | varchar(40) | YES  |     | NULL    |       |  <--- 새로 추가된 필드
+-------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

 

mysql> alter table friend change phone tel int(30) not null;
Query OK, 0 rows affected (0.05 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc friend;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| no    | int(11)     | YES  |     | NULL    |       |
| name  | varchar(15) | YES  |     | NULL    |       |
| tel   | int(30)     |      |     | 0       |       |           <--- 변경된 필드
| email | varchar(40) | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

 

mysql> alter table friend drop email;
Query OK, 0 rows affected (0.00 sec)
Records: 0  Duplicates: 0  Warnings: 0

2010년 4월 20일 화요일

Apache setting for PHP

1) http://archive.apache.org/dist/httpd/binaries/win32/

apache_2.0.43-win32-x86-no_ssl.msi

DOWNLOAD

 

// 아래 추가 부분 띄어쓰기도 중요함.

아래 추가 구문중에 오류가 있으면 아래와 같은 Error Message 뜸

The requested operation has failed!

 

2) C:\Program Files\Apache Group\Apache2\conf\httpd.conf

 

C:/Program Files/Apache Group/Apache2/htdocs  // 실제 php파일들 저장될 폴더 확인

EclipsePHP version의 workspace를 위와 동일한 폴더로 해주어야 이클립스에서도 프로젝트 생성후 실행됨. apache start 후에 실행할 때 run > PHP Web page로 실행

 

ServerName localhost:80 <-- 이부분 확인

 

ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache2/cgi-bin/"
ScriptAlias /php/ "C:/PHP4/" <-- 이부분 추가

 

AddType application/x-tar .tgz
AddType image/x-icon .ico
ScriptAlias /php4/ "c:/php4/" <-- 이부분 추가

AddType application/x-httpd-php4 .php .html .php3 .htm .inc <-- 이부분 추가
Action application/x-httpd-php4 "/php4/php.exe" <-- 이부분 추가

 

AddDefaultCharset EUC-KR <-- AddDefaultCharset ISO-8859-1 을 수정

 

3) C:/PHP4/ 에서 php.ini, php4ts.dll 두 파일 복사해서 C:\WINDOWS 에 붙여넣기

 

4) C:\PHP4\sapi 에서 php4apache2.dll 복사해서 C:\WINDOWS\system32 에 붙여넣기

 

 

Reference http://www.peoplepower.co.kr

PHP4 setting for beginner

1) http://museum.php.net/win32/

php-4.2.3-Win32.zip Download

 

2) php-4.2.3-Win32 c:\ 로 옮기고 PHP4로 폴더 이름 변경

 

3) PHP4 폴더 안에  php.ini-dist 를 php.ini로 이름 변경 후 메모장으로 열어 본다.

; Directory in which the loadable extensions (modules) reside.
extension_dir = ./

위 부분을 아래와 같이 고치고 저장한다.

; Directory in which the loadable extensions (modules) reside.
extension_dir = "C:\PHP4"

 

register_globals = Off --> register_globals = On

 

 

Reference http://www.peoplepower.co.kr

MySQL setting for beginner

1) mysql-3.23.53-win.zip Download

http://filekeeper.org/download/dc/mysql-3.23.53-win.zip

 

2) Install

setup > next > next > next > setting type : typical > finish

 

3) execute

시작 > 실행 > cmd >확인

C:\mysql\bin>mysqld.exe -install
Service successfully installed.

C:\mysql\bin>net start mysql
MySql 서비스를 시작합니다..
MySql 서비스가 잘 시작되었습니다.

C:\mysql\bin>mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 3.23.53-max-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> \q
Bye

C:\mysql\bin>net stop mysql
MySql 서비스를 멈춥니다..
MySql 서비스를 잘 멈추었습니다.

C:\mysql\bin>

 

 

 

Reference http://www.peoplepower.co.kr

2010년 4월 15일 목요일

Naver Site Search

Site Search 서비스는 별도의 프로그래밍 없이도 손쉽게 검색 서비스를 구현할 수 있도록 해 주는 네이버 제공 페이지 방식과,
xml 형식의 데이터만을 전송받아 자유롭게 UI를 꾸밀 수 있는 API방식으로 제공됩니다. 사용자는 제공되는 기능을 이용해서 자신의 사이트에 맞게 UI를 수정하실 수 있습니다.
그러나 Site Search는 하나의 공통 모듈을 이용해 다수의 사이트에 검색 결과를 제공하는 서비스이므로 각각의 사이트의 요구에 최적화된 기능들을 개별적으로 개발 및 지원해 드리지는 못합니다.

 

제휴기본 요건

  1. 1) 자체 검색 기능이 필요하다고 판단될 정도의 일정량의 자체 컨텐츠를 보유하고 있어야 하며, 보유한 컨텐츠가 저작권에 위배되지 않아야 합니다.
  2. 2) 사이트 컨텐츠에 성인, 폭력, 도박 등 반사회적, 불법적 내용이 포함되어 있어서는 안됩니다.
  3. 3) Site Search를 통해 제공되는 검색 결과는 네이버의 검색 색인에 포함되어 네이버 검색 결과에 노출될 수 있음을 동의하셔야 합니다.

 

http://sitesearch.naver.com/faq.nhn?menu=7

     

구글 지도 서비스 이용약관

Google 지도 서비스 약관

사용자가 Google 지도나 Google 지도를 통해 제공되는 데이터 또는 정보를 이용하는 것은 Google 서비스 약관뿐만 아니라 관련 추가 약관에도 동의한다는 것을 의미합니다. 개인 사용자의 경우, 지역정보 검색 결과, 지도 및 사진 이미지를 포함한 Google 지도 서비스는 오직 개인적, 비상업적 용도로만 이용할 수 있습니다. 비즈니스 사용자의 경우, Google 지도는 내부용으로만 이용할 수 있으며 상업적으로 재배포할 수 없습니다. 단, Google 지도 API를 사용하여 액세스 및 표시되는 지도 데이터는 API 이용약관에 의거해 예외로 합니다.

타사 제공 콘텐츠

Google 지도 서비스는 타사가 제공하는 업체 목록, 이미지 및 관련 정보와 같은 검색 결과를 포함합니다. 또한, Google 가젯과 같은 서비스를 통해 Google 지도에서 타사 콘텐츠를 이용하실 수도 있습니다. Google은 타사가 제공하는 정보의 정확성 또는 완성도에 대해 어떠한 진술이나 보증도 하지 않습니다. 사용자가 타사 콘텐츠를 사용할 경우 Google의 법적 고지 페이지에 있는 추가 약관이 적용될 수 있습니다.

지도 정보

Google 지도의 정보는 여정을 계획하기 위한 목적으로만 제공됩니다. 날씨, 공사 프로젝트, 교통 상황 등으로 인해 도로 상황이 지도에서 제시한 결과와 다를 수 있습니다.

Google 지도는 지명 및 지도 표기와 관련해 널리 공식적으로 인정되는 국제 표준을 따릅니다. 예를 들어 국가 및 영토 명칭은 UN 통계국이 공식 인정한 ISO-3166 기준을 주로 따르고 있습니다.

사진 이미지를 포함하여 지도 정보에 나타난 저작권, 상표 또는 기타 사유 재산권 통보는 삭제할 수 없으며, 어떠한 방식으로도 변경할 수 없습니다. Google 지도의 지도 콘텐츠 위치정보 지정 데이터는 Navteq North America LLC("NAVTEQ") 및 Tele Atlas North America, Inc.("TANA") 및/또는 기타의 라이센스 계약에 따라 제공되며, NAVTEQ, TANA 및 기타 타사가 소유하고 라이센스를 보유한 저작권 보호 및 기타 지적재산권의 대상이 됩니다. 본 정보를 사용하는 데도 역시 라이센스 계약의 약관이 적용됩니다. 사용자가 허가 없이 본 정보를 복사 또는 공개하는 경우 법적 책임을 물을 수 있으며, Google 지도를 사용하는 것은 NAVTEQ 및 TANA를 타사 수혜자로 삼는 데 동의하는 것을 의미합니다. 구체적으로 다음을 허가하는 라이센스를 Google로부터 부여받은 경우를 제외하고, Google 지도를 차량 네비게이션, 위치 찾기, 파견, 실시간 경로 안내, 차량 관리 및 유사한 응용프로그램에서 사용하도록 차량에 설치 또는 연결할 수 없으며, 차량과 통신할 수 있는 모든 제품, 시스템, 응용프로그램에 사용할 수 없습니다.

또한 Google 지도에서 본인이나 다른 사용자가 숫자로 표시된 위도 및 경도 좌표를 대량으로 다운로드하거나 대량으로 공급할 수 있도록 액세스 권한을 제공해서는 안됩니다.

미국 정부기관의 사용자의 경우 법적 고지 페이지의 "정부기관 사용자" 부분을 참조하시기 바랍니다.

Google 지도 API에 대해 자세히 알아보려면 여기를 클릭하시기 바랍니다.

사진 이미지

Google 지도를 통해 제공되는 사진 이미지는 사용자만이 이용할 수 있는 독점적이고 양도가 불가능한 라이센스 계약에 따라 제공됩니다. 이미지를 상업적 또는 비즈니스 환경에서 사용할 수 없으며 사용자 및 제 3자를 위한 어떠한 상업적 또는 비즈니스 목적으로도 이용할 수 없습니다.

사용자는 전체 또는 부분적으로 이미지를 복사, 역엔지니어링, 디컴파일, 분리, 변환, 수정 또는 파생물을 생성할 수 없습니다. 이미지 전체 또는 일부를 임대, 공개, 게시, 판매, 할당, 대여, 재라이센스, 시장 거래 또는 양도할 수 없으며 계약서에 명시적으로 승인되지 않은 어떠한 방식으로도 사용할 수 없습니다.

Google 지도 사용에 따라 이미지 상의 어떤 소유권을 보유하게 되는 것은 아니며, 이러한 소유권은 Google 및 기타 라이센스 제공자(해당되는 경우)가 모두 보유합니다. 이미지는 저작권의 보호를 받으며 다른 데이터 또는 소프트웨어와 병합 또는 수정되더라도 복사할 수 없습니다.

교통 정보

Google 지도의 교통 정보는 타사가 제공한 정보를 포함하며 오직 여정을 계획하기 위한 목적으로만 제공됩니다. Google은 본 정보의 정확성 및 완성도에 관해 어떠한 진술이나 보증도 하지 않습니다.

적절한 이용 및 금지된 행위

사용자는 Google 지도를 사용하는 동안 자신의 행위나 콘텐츠, 또한 이에 수반하는 결과에 대한 책임을 지는데 동의합니다. 사용자는 본 서비스 약관 및 기타 적용 가능한 정책 또는 가이드라인에 따라 합법적이고 적절한 목적으로만 Google 지도를 이용하기로 동의합니다. 예를 들어 Google 지도를 사용할 때 사용자는 다음과 같은 행위를 하지 않기로 동의합니다. (금지된 행위가 다음 예에만 국한되지는 않습니다.)

  • 명예 훼손, 폭력, 괴롭힘, 스토킹, 협박 또는 기타 타인의 법적 권리(개인정보 보호권 및 공개권)를 침해하는 행위,
  • 일체의 부적절, 비방적, 침해적, 외설적이거나 불법적인 콘텐츠를 업로드, 게시, 이메일 발송이나 전송 또는 기타 제공하는 행위,
  • 저작권 소유자가 아니거나 소유자로부터 콘텐츠 게시 허가를 받지 않은 경우, 당사자의 모든 특허권, 상표권, 저작권, 영업 비밀 및 기타 재산권을 침해하는 콘텐츠를 업로드, 게시, 이메일로 발송 또는 전송 또는 기타 제공하는 행위,
  • 피라미드 조직, 행운의 편지, 상업적 교란 메시지 또는 광고를 촉진하는 메시지, 또는 법률, 본 서비스 약관 또는 기타 적용가능한 정책 및 가이드라인이 금지하는 모든 내용을 업로드, 게시, 이메일 발송 또는 전송, 또는 제공하는 행위.
  • 파일이 합법적으로 배포될 수 없다는 사실을 알고 있거나 분명히 알고 있었을 것으로 추정되는 상황에서 다른 사람이 게시한 파일을 다운로드하는 행위,
  • 다른 사람 또는 다른 단체로 가장하거나 소프트웨어 등 기타 자료의 출처, 소스에 대한 모든 작성자 속성 및 법적 고지 등 해당 고지, 재산권 자격, 라벨을 위조하거나 삭제하는 행위,
  • 다른 사용자가 Google 서비스를 이용 및 향유할 수 없도록 제한하거나 방해하는 행위,
  • Google 서비스를 불법적 또는 인증되지 않은 목적을 위해 사용하는 행위,
  • Google 서비스 내의 저작권, 상표권, 기타 재산권 고지를 삭제하는 행위,
  • Google 서비스 자체 또는 Google 서비스에 연결된 서버, 네트워크를 방해하거나 중단시키는 행위 및 Google 서비스에 연결된 네트워크의 모든 요구사항, 절차, 정책, 규정을 어기는 행위,
  • 로봇, 스파이더, 사이트 검색 응용프로그램 등 기타 기기를 사용하여 Google 서비스의 일부를 검색하거나, 색인화하는 행위 및 인증되지 않은 목적을 위해 사용자에 대한 정보를 수집하는 행위,
  • Google의 후원 또는 추천을 받은 콘텐츠인 것처럼 거짓으로 표시되어 있거나 이를 암시하는 콘텐츠를 올리는 행위,
  • 자동화된 수단을 사용하거나 거짓으로 사용자 계정을 만드는 행위,
  • 불법 행위에 관해 안내하거나 정보를 제공하는 행위 및 모든 단체, 개인에 대한 물리적 위해 또는 상해를 촉진하는 행위,
  • 바이러스, 웜, 결함, 트로이 목마 등 파괴적 속성을 지닌 아이템을 전송하는 행위.

미국 이외 지역의 사용자는 미국 또는 사용자 거주 국가로의 데이터 수출을 규제하는 법을 포함하여 온라인 서비스 이용과 이용 가능한 콘텐츠에 대한 현지 규정을 준수하는데 동의합니다.

또한 본 서비스는 (a) 실시간 경로 안내(센서를 사용하는 턴 바이 턴 경로 안내 및 기타 경로 지정 서비스를 제한없이 포함)를 위한 목적이나 (b) 차량 운행을 자동 또는 자율적으로 조절하는 시스템 또는 기능에 연결하려는 목적으로는 사용될 수 없습니다.

 

From http://www.google.com/intl/ko_kr/help/terms_maps.html

2010년 4월 14일 수요일

네이버 지도 이용관련 정리

1. 네이버 오픈API 이용시 일반키와 제휴키의 차이는 사용량의 차이뿐이며 법인이라 하여도 사용양이 많지 않다면 일반키 사용해도 문제가 없다.

 

2. 상업용 사이트에서 사용 : 사전에 별도의 제휴를 통해서만 가능합니다. 네이버 오픈API 제휴를 참고

 

3. 현재로서는 1일 100,000 페이지 요청으로 서비스 제공을 제한. 일일 제한량을 초과하는 활용은 네이버 오픈API 제휴를 통해서 제공

4. 네이버 OPEN API를 사용한 직접적인 수익이 발생한다거나 api결과를 별도로 저장한다거나 하는 등의 이용이 아니라면 이용 가능.

 

5. open api를 이용하기 위한 key의 경우 key유출을 방지하기 위한 목적으로 레퍼러체크가 되도록 되어 있음. localhost에서 되지만 로컬파일들에서는 안되는 이유임. 즉 웹서버가 필요.

구글맵 라이센스, 무료로 사용가능한 범위

구글맵API는 기본적으로 무료로 사용가능한데 아래에 해당되지 않는 경우에 한합니다.

1. 유료회원제 사이트인경우(유료로 가입하지 않으면 이용이 안되는 사이트)
2. 사내인트라넷과 같은 비공개 사이트
3. 자산(부동산등), 차량추적을가지는 사이트(말하자면 내비게이션)

1,2,3에 해당되는 사이트는 연간 1만불정도의 금액으로 프리미엄 서비스를 이용하시면 됩니다.

참고 url : http://code.google.com/support/bin/answer.py?answer=55141&topic=14522


그리고 일일 쿼리제한입니다만...
기본적으로 IP어드레스에 대하여 1일 1만5천건이란 제한이 있습니다만
구글맵의 API는 자바스크립트 형식으로 구글서버에의 액세스는 클라이언트 PC가 처리를 하게 되오니
서버가 구글맵의 데이터를 다운로드하지 않는한 그다지 신경안써도 됩니다.

 

From : http://blog.lemonbrain.net/72

Weather Program

1) Class Diagram

2) Widget Images

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3) Google Weather API example

http://www.google.co.uk/ig/api?weather=london

<?xml version="1.0" ?>

- <xml_api_reply version="1">
- <weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0">
- <forecast_information>
  <city data="London, England" />
  <postal_code data="london" />
  <latitude_e6 data="" />
  <longitude_e6 data="" />
  <forecast_date data="2010-04-14" />
  <current_date_time data="2010-04-14 05:20:00 +0000" />
  <unit_system data="SI" />
  </forecast_information>
- <current_conditions>
  <condition data="대체로 흐림" />
  <temp_f data="45" />
  <temp_c data="7" />
  <humidity data="습도: 76%" />
  <icon data="/ig/images/weather/mostly_cloudy.gif" />
  <wind_condition data="바람: 북풍, 11 km/h" />
  </current_conditions>
.
.
 

2010년 4월 13일 화요일

Writing Real-Time Games for Android

From http://www.androidside.com/

Use SurfaceView

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1) /MyGraphics2D02/src/my/MyGraphics2D02/MyGraphics2D02.java

package my.MyGraphics2D02;
import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.Window;

public class MyGraphics2D02 extends Activity {
 
 class GraphicIcon { // 새로운 비트맵 아이콘들을 생성하기 위한 클래스를 추가
        private Bitmap bm;
        private Coordinates co; // 좌표처리
    
        public GraphicIcon(Bitmap bitmap) {
            bm = bitmap;
            co = new Coordinates();
        }
    
        public Bitmap getGraphic() {
            return bm;
        }
    
        public Coordinates getCoordinates() {
            return co;
        }
    
      
        public class Coordinates {
            private int x = 0;
            private int y = 0;
    
            public int getX() {
                return x;
            }
    
            public void setX(int value) {
                x = value - bm.getWidth() / 2;
            }
    
            public int getY() {
                return y;
            }
    
            public void setY(int value) {
                y = value - bm.getHeight() / 2;
            } 
          
        }
    }
 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Enable extended window features. This is a convenience for calling getWindow().requestFeature().
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(new CustomView(this));
    }
 
    class CustomView extends SurfaceView implements SurfaceHolder.Callback {
        private CustomViewThread CVThread;
        // ArrayList Graphics는 GraphicIcon클래스를 사용해 생성한 객체들을 저장
        private ArrayList<GraphicIcon> graphics = new ArrayList<GraphicIcon>();
        private int x = 70;
        private int y = 70;

        public CustomView(Context context) {
            super(context);
            getHolder().addCallback(this);
            CVThread = new CustomViewThread(getHolder(), this);
            setFocusable(true); // 해당  View가 touch mode에서 Focus가 가도록 지정합니다.
        }
 
        @Override
        public void onDraw(Canvas canvas) {
       
         Bitmap bm;
            canvas.drawColor(Color.parseColor("#dedede"));
            GraphicIcon.Coordinates co;
            // For문 : ArrayList graphics에 들어 있는 객체들을 하나씩 꺼내어 graphic변수에 저장하여 그림을 그림.
            for (GraphicIcon graphic : graphics) {
                bm = graphic.getGraphic();
                co = graphic.getCoordinates();
                canvas.drawBitmap(bm, co.getX(), co.getY(), null);
            }
        }
 
        @Override
        public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
            // TODO Auto-generated method stub
 
        }
 
        @Override
        public void surfaceCreated(SurfaceHolder holder) {
            CVThread.setRunning(true);
            CVThread.start();
        }
 
        @Override
        public void surfaceDestroyed(SurfaceHolder holder) {
           
            boolean retry = true;
            CVThread.setRunning(false);
            while (retry) {
                try {
                    CVThread.join();
                    retry = false;
                } catch (InterruptedException e) {
                   
                }
            }
        }
       
        public boolean onTouchEvent(MotionEvent event) {
         synchronized (CVThread.getSurfaceHolder()) { // ConcurrentModificationException 처리
          if(event.getAction()==MotionEvent.ACTION_DOWN){ //드레그해도 연속으로 생성되지 않게 함.
           GraphicIcon graphic = new GraphicIcon(BitmapFactory.decodeResource(getResources(), R.drawable.icon));
              graphic.getCoordinates().setX((int) event.getX());
              graphic.getCoordinates().setY((int) event.getY());
              graphics.add(graphic);
          }
          return true;
         }
        }


    }
 
    class CustomViewThread extends Thread {
        private SurfaceHolder surfaceholder;
        private CustomView customview;
        private boolean running = false;
        public SurfaceHolder getSurfaceHolder() {
            return surfaceholder;
        }

        public CustomViewThread(SurfaceHolder surfaceHolder, CustomView CustomView) {
            surfaceholder = surfaceHolder;
            customview = CustomView;
        }
 
        public void setRunning(boolean run) {
            running = run;
        }
 
        @Override
        public void run() {
            Canvas c;
            while (running) {
                c = null;
                try {
                    c = surfaceholder.lockCanvas(null);
                    synchronized (surfaceholder) {
                        customview.onDraw(c);
                    }
                } finally {
                   
                    if (c != null) {
                        surfaceholder.unlockCanvasAndPost(c);
                    }
                }
            }
        }
    }
}

2) Result image

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Reference http://www.androidside.com

2010년 4월 12일 월요일

Google MapView in Android

1) System confirm path

내컴퓨터 > 고급 > 환경변수 > path >

Add this path :

C:\android\tools;C:\Program Files\Java\jdk1.6.0_17\bin

 

2) Get the API Key

C:\>cd C:\Documents and Settings\%username%\.android\

C:\Documents and Settings\jp\.android>keytool -list -alias androiddebugkey -keys
tore debug.keystore -storepass android -keypass android
androiddebugkey, 2010. 4. 12, PrivateKeyEntry,
인증서 지문(MD5): B1:B9:5F:01??????????????????:27:BF:29:FA:67:5C:26

 

http://code.google.com/intl/ko/android/maps-api-signup.html

Sign Up for the Android Maps API

 

 

3) Create AVD

over level Google APIs Level 6

 

4) Create project

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

5) /HelloMyMap/AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="my.HelloMyMap"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-permission android:name="android.permission.INTERNET" /> 
    <application android:icon="@drawable/icon" android:label="@string/app_name">
     <uses-library android:name="com.google.android.maps" />
        <activity android:name=".HelloMyMap"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-sdk android:minSdkVersion="6" />

</manifest>

 

6) /HelloMyMap/res/layout/main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainlayout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <com.google.android.maps.MapView
        android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true"
        android:apiKey="00Q8dPkiSL???????????????v-PfctrXmOFA"
    />
       
</RelativeLayout>

 

7) /HelloMyMap/src/my/HelloMyMap/HelloItemizedOverlay.java

package my.HelloMyMap;
import java.util.ArrayList;
import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class HelloItemizedOverlay extends ItemizedOverlay {
 private Context mContext;
 private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
 
 public HelloItemizedOverlay(Drawable defaultMarker, Context context) {
    super(boundCenterBottom(defaultMarker));
    // TODO Auto-generated constructor stub
    mContext = context;
   }

  @Override
  protected OverlayItem createItem(int i) {
   // TODO Auto-generated method stub
   return mOverlays.get(i);
  }

  @Override
  public int size() {
   // TODO Auto-generated method stub
   return  mOverlays.size();
  }
 
  public void addOverlay(OverlayItem overlay) {
      mOverlays.add(overlay);
      populate();
  }
 
  @Override
  protected boolean onTap(int index) {
    OverlayItem item = mOverlays.get(index);
    AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
    dialog.setTitle(item.getTitle());
    dialog.setMessage(item.getSnippet());
    dialog.show();
    return true;
  }

}

8) /HelloMyMap/src/my/HelloMyMap/HelloMyMap.java

package my.HelloMyMap;

import java.util.List;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.ZoomControls;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

public class HelloMyMap extends MapActivity {
 
  List<Overlay> mapOverlays;
  Drawable drawable;
  HelloItemizedOverlay itemizedOverlay;
  LinearLayout linearLayout;
  MapView mapView;
  ZoomControls mZoom;

 @Override
    protected boolean isRouteDisplayed() {
        return false;
    }
 
/** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mapView = (MapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);
        mapView.setSatellite(false);
       
        GeoPoint p=new GeoPoint(53458671,-2267346);
        MapController mc=mapView.getController();       
        mc.animateTo(p);
        mc.setZoom(5);
       
        mapOverlays = mapView.getOverlays();
        drawable = this.getResources().getDrawable(R.drawable.androidmarker);
        itemizedOverlay = new HelloItemizedOverlay(drawable,this);
       
        OverlayItem overlayitem = new OverlayItem(p, "Hello", "Man Utd.");

        itemizedOverlay.addOverlay(overlayitem);
        mapOverlays.add(itemizedOverlay);
    }       
}

9) Result Images

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Reference http://www.androidside.com

TabWidget

 

1) /HelloTabWidget/res/values/attr.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
   <declare-styleable name="Gallery1">
        <attr name="android:galleryItemBackground" />
    </declare-styleable>
</resources>

 

2) /HelloTabWidget/res/layout/main.xml

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            
             <Gallery
       android:id="@+id/gallery"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
   />

            <LinearLayout
                android:id="@+id/textview2"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" 
                android:text="this is another tab">
                <TextView
     android:id="@+textview2/dateDisplay"           
     android:layout_width="wrap_content"           
     android:layout_height="wrap_content"           
     android:text=""/>   
    <Button
     android:id="@+textview2/pickDate"           
     android:layout_width="wrap_content"           
     android:layout_height="wrap_content"           
     android:text="Change the date"/>
            </LinearLayout>
           
            <TextView 
                android:id="@+id/textview3"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" 
                android:text="this is a third tab" />
               
        </FrameLayout>
    </LinearLayout>
</TabHost>


3) /HelloTabWidget/src/my/HelloTabWidget/HelloTabWidget.java

package my.HelloTabWidget;

import java.util.Calendar;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.TabActivity;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class HelloTabWidget extends TabActivity  {
 TabHost mTabHost = null;
 private TextView mDateDisplay;
 private Button mPickDate;

 private int mYear;
 private int mMonth;
 private int mDay;

 static final int DATE_DIALOG_ID = 0;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
        mTabHost = getTabHost();
        
        mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("TAB 1", getResources().getDrawable(R.drawable.icon1)).setContent(R.id.gallery));
        mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("TAB 2", getResources().getDrawable(R.drawable.icon2)).setContent(R.id.textview2));
        mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("TAB 3", getResources().getDrawable(R.drawable.icon3)).setContent(R.id.textview3));
        
        mTabHost.setCurrentTab(0);
       
        Gallery g = (Gallery) findViewById(R.id.gallery);
        g.setAdapter(new ImageAdapter(this));

        g.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView parent, View v, int position, long id) {
                Toast.makeText(HelloTabWidget.this, "" + (position+1), Toast.LENGTH_SHORT).show();
            }
        });
       
     // capture our View elements
        mDateDisplay = (TextView) findViewById(R.textview2.dateDisplay);
        mPickDate = (Button) findViewById(R.textview2.pickDate);

        // add a click listener to the button
        mPickDate.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                showDialog(DATE_DIALOG_ID);
            }
        });

        // get the current date
        final Calendar c = Calendar.getInstance();
        mYear = c.get(Calendar.YEAR);
        mMonth = c.get(Calendar.MONTH);
        mDay = c.get(Calendar.DAY_OF_MONTH);

        // display the current date
        updateDisplay();
    }
   
    @Override
    protected Dialog onCreateDialog(int id) {
        switch (id) {
        case DATE_DIALOG_ID:
            return new DatePickerDialog(this,
                        mDateSetListener,
                        mYear, mMonth, mDay);
        }
        return null;
    }
   
    private void updateDisplay() {
        mDateDisplay.setText(
            new StringBuilder()
                    // Month is 0 based so add 1
              .append(mYear).append("-")
                    .append(mMonth + 1).append("-")
                    .append(mDay).append(" "));
    }
   
    private DatePickerDialog.OnDateSetListener mDateSetListener =
        new DatePickerDialog.OnDateSetListener() {

            public void onDateSet(DatePicker view, int year,
                                  int monthOfYear, int dayOfMonth) {
                mYear = year;
                mMonth = monthOfYear;
                mDay = dayOfMonth;
                updateDisplay();
            }
        };
   
    public class ImageAdapter extends BaseAdapter {
        int mGalleryItemBackground;
        private Context mContext;

        private Integer[] mImageIds = {
                R.drawable.f1,
                R.drawable.f2,
                R.drawable.f3,
                R.drawable.f4,
                R.drawable.f5,
                R.drawable.f6
        };

        public ImageAdapter(Context c) {
            mContext = c;
            TypedArray a = obtainStyledAttributes(R.styleable.Gallery1);
            mGalleryItemBackground = a.getResourceId(
                    R.styleable.Gallery1_android_galleryItemBackground, 0);
            a.recycle();
        }

        public int getCount() {
            return mImageIds.length;
        }

        public Object getItem(int position) {
            return position;
        }

        public long getItemId(int position) {
            return position;
        }

        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView i = new ImageView(mContext);

            i.setImageResource(mImageIds[position]);
            i.setLayoutParams(new Gallery.LayoutParams(150, 100));
            i.setScaleType(ImageView.ScaleType.FIT_XY);
            i.setBackgroundResource(mGalleryItemBackground);

            return i;
        }
    }
}

4) Relsult Images

Form configuration components

1) /HelloFormStuff/res/layout/main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:padding="10dip"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >
<ImageButton
    android:id="@+id/android_button"
    android:layout_width="100dip"
    android:layout_height="wrap_content"
    android:src="@drawable/android" />  
<EditText
    android:id="@+id/edittext"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"/>  
<CheckBox android:id="@+id/checkbox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="check it out" />
<RadioGroup
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:orientation="horizontal">
 
  <RadioButton android:id="@+id/radio_red"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Red" />
 
  <RadioButton android:id="@+id/radio_blue"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Blue" />
</RadioGroup>
<ToggleButton android:id="@+id/togglebutton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip"
        android:text="Please select a planet:"
    />
<Spinner android:id="@+id/spinner"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:drawingCacheQuality="high"
        android:prompt="@string/planet_prompt"
    />
</LinearLayout>

2) /HelloFormStuff/res/values/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="hello">Hello World, HelloFormStuff!</string>
    <string name="app_name">HelloFormStuff</string>
    <string name="planet_prompt">Choose a planet</string>
</resources>

3) /HelloFormStuff/res/values/arrays.xml
<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <string-array name="planets">
        <item>Chelsea</item>
        <item>ManUtd</item>
        <item>Arsenal</item>
        <item>ManCity</item>
        <item>Tottenham</item>
        <item>Liverpool</item>
        <item>AstonVilla</item>
        <item>Everton</item>
    </string-array>
</resources>

4) /HelloFormStuff/src/my/HelloFormStuff/HelloFormStuff.java
package my.HelloFormStuff;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.Toast;
import android.view.KeyEvent;
import android.view.View.OnKeyListener;
import android.widget.EditText;
import android.widget.CheckBox;
import android.widget.RadioButton;
import android.widget.ToggleButton;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

public class HelloFormStuff extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        final ImageButton button = (ImageButton) findViewById(R.id.android_button);
        button.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                // Perform action on clicks
                Toast.makeText(HelloFormStuff.this, "I love Liverpool", Toast.LENGTH_LONG).show();
            }
        });
        
        final EditText edittext = (EditText) findViewById(R.id.edittext);
        edittext.setOnKeyListener(new OnKeyListener() {
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                  // Perform action on key press
                  Toast.makeText(HelloFormStuff.this, edittext.getText(), Toast.LENGTH_SHORT).show();
                  return true;
                }
                return false;
            }
        });
        
        final CheckBox checkbox = (CheckBox) findViewById(R.id.checkbox);
        checkbox.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                // Perform action on clicks
                if (checkbox.isChecked()) {
                    Toast.makeText(HelloFormStuff.this, "Selected", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(HelloFormStuff.this, "Not selected", Toast.LENGTH_SHORT).show();
                }
            }
        });
        
        final ToggleButton togglebutton = (ToggleButton) findViewById(R.id.togglebutton);
        togglebutton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                // Perform action on clicks
                if (togglebutton.isChecked()) {
                    Toast.makeText(HelloFormStuff.this, "ON", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(HelloFormStuff.this, "OFF", Toast.LENGTH_SHORT).show();
                }
            }
        });
        
        Spinner s = (Spinner) findViewById(R.id.spinner);
        ArrayAdapter adapter = ArrayAdapter.createFromResource(
                this, R.array.planets, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        s.setAdapter(adapter);
        
        final RadioButton radio_red = (RadioButton) findViewById(R.id.radio_red);
        final RadioButton radio_blue = (RadioButton) findViewById(R.id.radio_blue);
        radio_red.setOnClickListener(j_listener);
        radio_blue.setOnClickListener(j_listener);
        
    }
    
    OnClickListener j_listener = new OnClickListener() {
        public void onClick(View v) {
            // Perform action on clicks
            RadioButton rb = (RadioButton) v;
            Toast.makeText(HelloFormStuff.this, rb.getText(), Toast.LENGTH_SHORT).show();
        }
    };
}

5) Result Image

Reference http://www.androidside.com

Linear Layout Example

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"   
android:orientation="vertical"    android:layout_width="fill_parent"   
android:layout_height="fill_parent">   
 <LinearLayout        android:orientation="horizontal"       
 android:layout_width="fill_parent"       
 android:layout_height="fill_parent"       
 android:layout_weight="1">               
  <TextView           
  android:text="red"           
  android:gravity="center_horizontal"           
  android:background="#aa0000"           
  android:layout_width="wrap_content"           
  android:layout_height="fill_parent"           
  android:layout_weight="1"/>               
  <TextView           
  android:text="green"           
  android:gravity="center_horizontal"           
  android:background="#00aa00"           
  android:layout_width="wrap_content"           
  android:layout_height="fill_parent"           
  android:layout_weight="1"/>               
  <TextView           
  android:text="blue"           
  android:gravity="center_horizontal"           
  android:background="#0000aa"           
  android:layout_width="wrap_content"           
  android:layout_height="fill_parent"           
  android:layout_weight="1"/>               
  <TextView           
  android:text="yellow"           
  android:gravity="center_horizontal"           
  android:background="#aaaa00"           
  android:layout_width="wrap_content"           
  android:layout_height="fill_parent"           
  android:layout_weight="1"/>                   
 </LinearLayout>           
 <LinearLayout       
 android:orientation="vertical"       
 android:layout_width="fill_parent"       
 android:layout_height="fill_parent"       
 android:layout_weight="1">               
  <Button           
  android:text="row one"           
  android:textSize="15pt"           
  android:layout_width="fill_parent"           
  android:layout_height="wrap_content"           
  android:layout_weight="1"/>               
  <Button           
  android:text="row two"           
  android:textSize="15pt"           
  android:layout_width="fill_parent"           
  android:layout_height="wrap_content"           
  android:layout_weight="1"/>               
  <Button           
  android:text="row three"           
  android:textSize="15pt"           
  android:layout_width="fill_parent"           
  android:layout_height="wrap_content"           
  android:layout_weight="1"/>               
  <Button           
  android:text="row four"           
  android:textSize="15pt"           
  android:layout_width="fill_parent"           
  android:layout_height="wrap_content"           
  android:layout_weight="1"/>           
 </LinearLayout>       
</LinearLayout>

 

 

Reference http://www.androidside.com