image

 

이것은 안드로이드 Tab UI 를 구성하는 구성요소 입니다.

안드로이드 Tab UI 는 이와같이 세 개의 다른 클래스들의 집합으로 이루어져 있습니다.

 

TabHost 는 TabUI 를 구성하는 전체 틀 입니다.

여기에는 특정한 android:id 를 가지는 TabWidget 와 TabSpec 이 포함되어야 합니다.

 

TabWidget 는  TabUI 에서 선택하는 버튼이 나오는 부분을 말하며 이것의 android:id 는 반드시 “@android:id/tabs” 가 되어야 합니다.

 

TabSpec 는 하나의 탭을 구성하는 구성요소들의 집합으로서 View 의 하위구성요소가 아니기 때문에 layout xml 파일에 직접 추가될 수 없습니다. 그래서 java 소스코드상으로 추가해 주어야 하며 layout xml 에는 이를 표시하기 위하여 “@android:id/tabcontent” 라는 android:id 를 가지는 Layout View 가 추가되어 있어야 합니다.

 

 

이렇게 글로만 보면 상당히 어렵게 보이는데 이것을 쉽게 쓰도록 만들어 놓은것이 바로 TabActivity 클래스 입니다.

아래는 TabActivity 를 이용하여 layout xml 파일 없이 TabUI 를 구성하는 예 입니다.

package net.cranix.android.cranixcontact;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;

public class CranixContact extends TabActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

final TabHost tabHost = getTabHost();
tabHost.addTab(
tabHost.newTabSpec("tab1")
.setIndicator("Contacts")
.setContent(new Intent(this,ContactsTabActivity.class))
);
tabHost.addTab(
tabHost.newTabSpec("tab2")
.setIndicator("Calllog")
.setContent(new Intent(this,CalllogTabActivity.class))
);
}
}

위의 소스에는 layout xml 파일이 사용되는 부분이 없지만 TabActivity 내부적으로 기본적인 layout 을 사용하고 있습니다.

그렇다면 TabActivity 에서 사용하는 기본적인 layout 은 무엇일까요?

 

안드로이드 소스를 직접 다운받아서 xml 파일을 뒤져보면 아래와 같은 레이아웃 파일을 발견할 수 있습니다.

<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TabWidget android:id="@android:id/tabs"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0" />
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"/>
</LinearLayout>
</TabHost>

이것이 바로 TabActivity 클래스가 기본으로 사용하는 layout xml 파일입니다.

위에서 말로 설명한 부분에 나와있는 대로 구성되어있는것을 확인할 수 있습니다.

 

TabActivity 를 상속받은 Activity 라면 기본적으로 위와같은 layout xml 파일이 contentView 로 자동으로 셋팅됩니다.

이것을 염두해 두고 개발을 해야지 오류를 피할수 있습니다.

 

그럼 내가만든 layout xml 을 TabActivity 에 띄우는 예제를 만들어 보겠습니다.

먼저 layout 을 구성합니다 파일이름은 main.xml 입니다.

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:text="@+id/TextView01"
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button android:text="@+id/Button01"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</FrameLayout>

 

이것을 TabActivity 에 띄우는 java 코드는 아래와 같습니다.

package net.cranix.android.testtabactivity;

import android.app.TabActivity;
import android.os.Bundle;
import android.widget.TabHost;

public class TestTabActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
final TabHost tabHost = getTabHost();

getLayoutInflater().inflate(R.layout.main, tabHost.getTabContentView());

tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("tab1").setContent(R.id.TextView01));
tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("tab2").setContent(R.id.Button01));
}
}
 
 
TabSpec.setContent 에 view 를 지정하려면 반드시 @”android:id/tabcontent” 의 하위 뷰 여야 합니다.
그래서 자신이 만든 layout 을 기존에 있던 tabHost 의 tabContentView 에 inflate 를 활용하여 붙혀주는 것 입니다.

 

위의 굵은 글씨에 의해 inflat 가 실행된 이후에는 layout 을 아래와 같이 인식합니다.

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TabWidget android:id="@android:id/tabs"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_weight="0" />
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
<TextView android:text="@+id/TextView01"
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button android:text="@+id/Button01"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</FrameLayout>
</LinearLayout>
</TabHost>

결국 위와 같이 tabSpec 을 만들때 setContent 에다가 자신이 만든 layout 을 사용할 수 있게 되는것 입니다.

 

이렇게 TabActivity 가 돌아가는 구조를 알아내면 응용도 가능합니다.

아래 예제는 안드로이드 TabUI 에서 TabWidget 이 아래에 있도록 구성한 Activity 입니다.

먼저 layout 파일은 아래와같이 구성합니다.

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
<TextView android:text="@+id/TextView01"
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button android:text="@+id/Button01"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</FrameLayout>
<TabWidget android:id="@android:id/tabs"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_weight="0" />
</LinearLayout>
</TabHost>

 

그다음 Activity 파일은 아래와 같이 구성합니다.

package net.cranix.android.testtabactivity;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TabHost;

public class TestTabActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final TabHost tabHost = (TabHost) findViewById(R.id.tabhost);
tabHost.setup();

tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("tab1").setContent(R.id.TextView01));
tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("tab2").setContent(R.id.Button01));
}
}

실행해 보면 아래와 같이 탭이 아래에 있는것을 볼 수 있습니다.

 

image

 

여기서 중요한 것은 TabActivity 가 아니라 그냥 Activity 를 이용하였다는 것과 레이아웃 파일을 안드로이드 TabUI 에 맞게 직접 구성했다는점 입니다.

이렇게 TabActivity 를 통하지 않고 Tab 을 구현할 경우에는 반드시 tabHost.setup() 을 호출해 주어야 합니다.

여기서 TabHost view 하위에 있는 기본 뷰를 탐색해서 셋팅해 주게 됩니다.

즉 이 함수를 거치면 tabHost.getTabWidget() 과 tabHost.getTabContentView() 같은 메소드를 사용할때 null 이 반환되지 않게 됩니다.

 

결국 안드로이드 TabUI 는 기본적인 안드로이드 UI 구조를 가지고 TabUI 를 구성하기 편하게 상속하여 재작성 한 것입니다.

by cranix 2011. 1. 5. 15:49

안드로이드 SDK 에는 프레임웍 소스가 포함되어 있지 않습니다.

그러나 안드로이드 어플을 개발하다보면 프레임웍쪽 소스코드를 확인해 보고싶을때가 있습니다.

이번 포스트에서는 이클립스에서 편하게 안드로이드 프레임웍 소스를 따라갈 수 있도록 셋팅하는법을 알아보도록 하겠습니다.

 

 

1. 프레임웍 소스코드 다운받기

 

안드로이드 소스크도는 git 로 관리되기 때문에 윈도우에서 받으려면 윈도우용 git 클라이언트를 사용해야 합니다.

그래서 Tortoise 같은 git 클라이언트인 msysgit 를받아서 설치합니다.

 

http://code.google.com/p/msysgit/downloads/list

 

리스트중 “Git-1.7.3.1-preview20101002.exe” 를 다운로드 합니다.

 

설치하고 git-gui 를 실행하면 아래와 같은 화면이 나옵니다.

 

image

 

여기서 “Clone Existing Repository” 를 선택하면 다음과 같은 화면이 나옵니다.

 

image

 

여기에 Source Location 은 “git://android.git.kernel.org/platform/frameworks/base.git” 으로 입력하고 Target Directory 는 적절히 선택해서 “Clone” 버튼을 클릭합니다.

 

image

 

이와 같은 화면이 나오는데 여기서 상당히 오래 걸립니다.

다운된거 같지만 다운된게 아니니 기다려주세요.(약 10분)

 

작업이 완료되면 아래와 같은 화면이 나옵니다.

image

 

이제 위에서 지정했던 “Target Directory” 를 확인해보면 소스코드가 다운받아져 있는것을 확인할 수 있습니다.

 

 

 

2. 이클립스 안드로이드 라이브러리에 소스코드 연결시키기

 

이클립스의 안드로이드 프로젝트의 Properties > Java Build Path 에 들어가서 Libraries 탭에 갑니다.

image

위와 같이 android.jar 파일의 Source attachment 가 none 으로 셋팅되어 있는것을 볼 수 있습니다.

이것을 더블클릭해서 “External Folder” 를 클릭합니다.

아래와 같이 소스를 다운받은 “Target Directory” 아래에 “core/java” 디렉토리를 선택합니다.

 

image

 

 

이제 아래와 같이 마음껏 프레임웍 소스를 확인할 수 있습니다.

image

by cranix 2011. 1. 4. 15:54

톰켓홈에서 tar.gz 바이너리 다운로드

wget http://apache.tt.co.kr/tomcat/tomcat-7/v7.0.5-beta/bin/apache-tomcat-7.0.5.tar.gz

 

 

압축해제

tar -zxvf apache-tomcat-7.0.5.tar.gz

 

 

tomcat 디렉토리 생성

mkdir /usr/local/tomcat

 

 

압축푼 톰켓 디렉토리 복사

mv apache-tomcat-7.0.5 /usr/local/tomcat/

 

심볼릭 링크 생성

cd /usr/local/tomcat

ln –s apache-tomcat-7.0.5/ default

 

실행확인

cd /usr/local/tomcat/default/bin

./startup.sh

[브라우저로 http://localhost:8080] 접속

 

 

시작프로그램에 등록

/etc/init.d/tomcat 스크립트 작성

#!/bin/sh
#
# Tomcat7 auto-start
#
# chkconfig: 2345 90 90
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid
case $1 in
start)
    sh /usr/local/tomcat/default/bin/startup.sh
    ;;
stop)
    sh /usr/local/tomcat/default/bin/shutdown.sh
    ;;
restart)
    sh /usr/local/tomcat/default/bin/shutdown.sh
    sh /usr/local/tomcat/default/bin/startup.sh
    ;;
esac
exit 0

'알짜정보 > Linux server' 카테고리의 다른 글

snmpwalk 사용법  (12) 2012.12.16
centos 에 시작프로그램 등록하기.  (41) 2012.12.15
cent os svn server 설치  (28) 2011.01.02
cent os 런레벨  (30) 2011.01.02
cent os chkconfig 이용해서 시작프로그램 등록하기  (61) 2011.01.02
by cranix 2011. 1. 3. 10:36
svn 설치 & mod_dav_svn 설치
yum install subversion
yum install mod_dav_svn  (아파치와 svn 연동을 위한 모듈)

유저별 svn 저장소 만들기
$ mkdir svnroot
$ cd svnroot
$ svnadmin create cranix (레퍼지토리 cranix 만들기)
$ htpasswd -c htsvnusers cranix (레퍼지토리에 접근할 수 있는 user 만들기)
$ chgrp -R apache cranix (레퍼지토리 에 apache 권한 주기)
$ chmod -R g+w cranix (그룹에 쓰기권한 주기)


virtual host 파일 만들기
<VirtualHost *:80>
        ServerName svn.cranix.net
        <Location "/">
                DAV svn
                SVNParentPath /home/cranix/svnroot
                AuthType Basic
                AuthName "cranix repository"
                AuthUserFile /home/cranix/svnroot/htsvnusers
                Require valid-user
                Order Deny,Allow
                Allow from all
        </Location>
</VirtualHost>

아파치를 리스타트 하고 http://svn.cranix.net/cranix 형태로 접근 가능

htpasswd 를 이용한 사용자 추가/변경/삭제
htpasswd htsvnusers cranix (만약에 있다면 변경 없다면 추가)
htpasswd -D htsvnusers cranix (cranix 유저 삭제)


 

'알짜정보 > Linux server' 카테고리의 다른 글

centos 에 시작프로그램 등록하기.  (41) 2012.12.15
cent os tomcat7 설치  (37) 2011.01.03
cent os 런레벨  (30) 2011.01.02
cent os chkconfig 이용해서 시작프로그램 등록하기  (61) 2011.01.02
cent os vsftp 설치하기  (23) 2011.01.02
by cranix 2011. 1. 2. 21:53

런레벨 확인
runlevel


런레벨 종류
- 런레벨 0 : Shutdown 모드
- 런레벨 1 : 싱글모드 부팅
- 런레벨 2 : NFS 를 사용하지 않는 다중 사용자 모드
- 런레벨 3 : 콘솔모드로 부팅 (기본 부팅상태)
- 런레벨 4 : 사용하지 않음
- 런레벨 5 : X 윈도우로 부팅
- 런레벨 6 : 지속적인 재부팅


런레벨에 따른 시작 프로그램 디렉토리
- /etc/rc.d/init.d/rcx.d


'알짜정보 > Linux server' 카테고리의 다른 글

cent os tomcat7 설치  (37) 2011.01.03
cent os svn server 설치  (28) 2011.01.02
cent os chkconfig 이용해서 시작프로그램 등록하기  (61) 2011.01.02
cent os vsftp 설치하기  (23) 2011.01.02
cent os apache virtual host 설정  (18) 2011.01.02
by cranix 2011. 1. 2. 21:21


1. 등록된 런레벨 확인하기
chkconfig --list [이름]

2. 런레벨에 등록하기
chkconfig --levell 1 httpd on





'알짜정보 > Linux server' 카테고리의 다른 글

cent os svn server 설치  (28) 2011.01.02
cent os 런레벨  (30) 2011.01.02
cent os vsftp 설치하기  (23) 2011.01.02
cent os apache virtual host 설정  (18) 2011.01.02
cent os php 설치  (35) 2011.01.02
by cranix 2011. 1. 2. 21:17

설치
yum install vsftpd


설정파일
/etc/vsftpd/vsftpd.conf

설정하기
1. 단순하게 사용자 계정에 chroot 설정
chroot_local_user=YES
2. 특정 사용자만 chroot 설정
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list

3. 특정 사용자를 제외한 나머지 사용자만 chroot 설정
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list

4. 계정마다 동적으로 설정할 경우
chroot_local_user=YES
passwd_chroot_enable=YES

이런식으로 하면 /etc/passwd 파일을 참고하여 chroot 를 설정할 수 있다.
아래와 같은 형태로 passwd 파일을 셋팅하면 "." 이 있는곳이 루트 디렉토리가 된다.
cranix:x:500:500::/home/./cranix:/bin/bash

'알짜정보 > Linux server' 카테고리의 다른 글

cent os 런레벨  (30) 2011.01.02
cent os chkconfig 이용해서 시작프로그램 등록하기  (61) 2011.01.02
cent os apache virtual host 설정  (18) 2011.01.02
cent os php 설치  (35) 2011.01.02
cent os mysql 설치  (30) 2011.01.02
by cranix 2011. 1. 2. 20:41

NameVirtualHost *:80

<VirtualHost *:80>
ServerName domain1
...
</VirtualHost>


<VirtualHost *:80>
ServerName domain2
...
</VirtualHost>


<VirtualHost *:80>
ServerName domain3
...
</VirtualHost>

'알짜정보 > Linux server' 카테고리의 다른 글

cent os chkconfig 이용해서 시작프로그램 등록하기  (61) 2011.01.02
cent os vsftp 설치하기  (23) 2011.01.02
cent os php 설치  (35) 2011.01.02
cent os mysql 설치  (30) 2011.01.02
cent os apache 설치  (28) 2011.01.02
by cranix 2011. 1. 2. 19:57

php 설치
yum install php
yum install php-mysql
yum install php-gd

php 설치확인(버젼확인)
php -version
php 업로드 설정
php.ini 파일에 다음을 수정

file_uploads = On
post_max_size = 150M // post 방식 업로드 사이즈
upload_max_filesize = 128M // 한번에 올릴수 있는 업로드 사이즈
max_input_time = -1  // 입력 데이터를 받아들이는 최대 시간 (기본60,-1 무한대)
max_ececution_time = 0 // PHP 스크립트 최대 실행시간 (기본 30, 0 무한대)
memory_limit = 128M // post_max_size > upload_max_filesize >= memory_limit 이어야 하며 memory_limit 가 최대 업로드 사이즈다.

최대 업로드 사이즈는 2G 가 넘지 않아야 에러가 없다.



php.ini 위치
/etc/php.ini

'알짜정보 > Linux server' 카테고리의 다른 글

cent os vsftp 설치하기  (23) 2011.01.02
cent os apache virtual host 설정  (18) 2011.01.02
cent os mysql 설치  (30) 2011.01.02
cent os apache 설치  (28) 2011.01.02
cent os java 설치  (56) 2011.01.02
by cranix 2011. 1. 2. 19:09

mysql 인스톨
yum install mysql
yum install mysql-server
mysql 인스톨후 데이터베이스 설치
/usr/bin/mysql_secure_installation

mysql 시작과 종료
/etc/init.d/mysqld start/stop

mysql charset 확인하기
mysql -uroot -p
> status;
or
> \s
or
> show variables like '%c';
mysql charset utf-8 설정하기
vi /etc/my.cnf
다음 추가
[mysql]
default-character-set = utf8

[mysqld]
...
character-set-client-handshake=FALSE
init_connect="SET collation_connection = utf8_general_ci"
init_connect="SET NAMES utf8"
default-character-set = utf8
character-set-server = utf8
collation-server = uf8_general_ci (이것때문에 서버 시작 안되는 경우있으니 주의할것.)

[client]
default-character-set = utf8

[mysqldump]
default-character-set = utf8

'알짜정보 > Linux server' 카테고리의 다른 글

cent os apache virtual host 설정  (18) 2011.01.02
cent os php 설치  (35) 2011.01.02
cent os apache 설치  (28) 2011.01.02
cent os java 설치  (56) 2011.01.02
cent os 기본정보 확인  (24) 2010.12.30
by cranix 2011. 1. 2. 18:51
| 1 2 3 4 5 6 ··· 10 |