노무현 전 대통령 서거 추모글 남기기

'전공'에 해당되는 글 64건

  1. 2010.02.01 안드로이드 host 파일 수정하기
  2. 2009.12.15 안드로이드- 나인패치
  3. 2009.12.08 안드로이드 쓰레드 관련
  4. 2009.11.18 안드로이드
  5. 2009.10.12 안드로이드 강좌
remount 한다.
>adb remount

안드로이드에 있는 host 파일을 받는다.
>adb pull /system/etc/hosts D:\TDPlatform\android_home\backup\

hosts 파일 수정한다.
---------------------------------------
기본적으로 로컬만 등록되어 있음.
127.0.0.1      localhost
---------------------------------------

host 파일을 넣는다.
>adb push D:\TDPlatform\android_home\work\hosts /system/etc/


hosts 파일 수정 확인해보기

>adb -e shell
#cat /system/etc/hosts
Posted by Kelly Cook
,

Nine-Patch Stretchable Image

Android supports a stretchable bitmap image. This is a PNG image in which you define stretchable sections that Android will resize to fit the object at display time to accommodate variable sized sections, such as text strings. You typically assign this resource to the View's background. An example use of a stretchable image is the button backgrounds that Android uses; buttons must stretch to accommodate strings of various lengths.

A NinePatch drawing is a standard PNG image that includes a 1 pixel wide border. This border is used to define the stretchable and static areas of the screen. You indicate a stretchable section by drawing one or more 1 pixel wide black lines in the left or top part of this border. You can have as many stretchable sections as you want. The relative size of the stretchable sections stays the same, so the largest sections always remain the largest.

You can also define an optional drawable section of the image (effectively, the padding lines) by drawing a line on the right and bottom lines. If you do not draw these lines, the first top and left lines will be used.

If a View object sets this graphic as a background and then specifies the View object's text, it will stretch itself so that all the text fits inside the area designated by the right and bottom lines (if included, the first top and left lines otherwise). If the padding lines are not included, Android uses the left and top lines to define the writeable area.

Here is a sample NinePatch file used to define a button.

Raw ninepatch file showing the definition lines

This ninepatch uses one single stretchable area, and it also defines a drawable area.

Here are two buttons based on this graphic. Notice how the width and height of the button varies with the text, and the background image stretches to accommodate it.

Two buttons based on the NinePatch button background

Source file format: PNG -- one resource per file

Resource source file location: res/drawable/somename.9.png (must end in .9.png)

Compiled resource datatype: Resource pointer to a NinePatchDrawable

Resource reference name:

  • Java R.drawable.somefile
  • XML @[package:]drawable.somefile

Example Code Use

Example XML code

Note that the width and height are set to "wrap_content" to make the button fit neatly around the text.

<Button id="@+id/big"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerInParent="true"
        android:text="Tiny"
        android:textSize="8sp"
        android:background="@drawable/my_button_background"/>
      
<Button id="@+id/big"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerInParent="true"
        android:text="Biiiiiiig text!"
        android:textSize="30sp"
        android:background="@drawable/my_button_background"/>

Posted by Kelly Cook
,


 


1. HandlerDemo

public class HandlerDemo extends Activity {
	ProgressBar bar;
	Handler handler=new Handler() {
		@Override
		public void handleMessage(Message msg) {
			bar.incrementProgressBy(5);
		}
	};
	boolean isRunning=false;
	
	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		setContentView(R.layout.main);
		bar=(ProgressBar)findViewById(R.id.progress);
	}
	
	public void onStart() {
		super.onStart();
		bar.setProgress(0);
		
		Thread background=new Thread(new Runnable() {
			public void run() {
				try {
					for (int i=0;i<20 && isRunning;i++) {
						Thread.sleep(10000);
						handler.sendMessage(handler.obtainMessage());
					}
				}
				catch (Throwable t) {
					// just end the background thread
				}
			}
		});
		
		isRunning=true;
		background.start();
	}
	
	public void onStop() {
		super.onStop();
		isRunning=false;
	}
}

.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:orientation="vertical"
	android:layout_width="fill_parent"
	android:layout_height="fill_parent"
	>
	<ProgressBar android:id="@+id/progress"
		style="?android:attr/progressBarStyleHorizontal"
		android:layout_width="fill_parent"
		android:layout_height="wrap_content" />
</LinearLayout>




[android] 메시지 핸들러(Handler) 사용하기
http://blog.daum.net/hopefullife/94

Handler 는 내부적으로 쓰레드를 생성해 메시지큐의 데이터의 입출력을 처리하는 녀석이다.

메시지큐에 메시지를 전송하거나 해당 메시지를 얻어올수 있다.

메시지를 전송할때 지연시간을 두어 전송토록 하는 메쏘드도 포함되어 있어

쓰레드간 메시지 스케줄링시 이래저래 많이 사용된다.

 

1. 메시지를 수신할 녀석을 설정한다.

public Handler handler = new Handler() {

@Override

public void handleMessage(Message msg)

{

 

}

};

 

별거읍넹.. 이렇게 설정하면 해당 쓰레드의 메시지 큐에 메시지가

존재하는 경우 handleMessage() 메쏘드가 호출된다.

 

switch( msg.what ) {

 

}

 

과 같이 handleMessage() 메쏘드에 메시지 처리루틴을 넣어주면 된다.

 

2. 메시지 만들기

쓰레드마다 메시지큐가 생성되므로, 다른쓰레드에서 위의 핸들러에 메시지를

보내기 위해서는 다른쓰레드에서 위의 handler 객체에 접근가능해야 한다.

 

싱글턴을 사용하던, static 멤버를 사용해 만들던, 위 객체를 접근가능하게 한뒤

메시지를 하나 만든다.

new Message로 만들어도 되나, 매번 객체가 생성되는 단점이 있으므로

핸들러에게 메시지를 하나 달라고 요청하는 방식을 사용한다.

그리고, 해당 메시지를 원하는 값을 설정한다.

 

Message msg = handler.obtainMessage();

msg.what = 1234;

msg.arg1 = 1111;

msg.arg2 = 2222;

msg.object = Object;

 

위를 하나로 처리할 수도 있는데,

Message msg = Message.obtain( handler, 1234, 111, 222 );

 

요렇게 해도 된다.

 

3. 메시지 전송

handler.sendMessage(msg);

 

메시지 전송은 여러 메쏘드 들이 존재한다.


Posted by Kelly Cook
,

 안드로이드에서 전체화면을 사용하기 위해서는 상태바(Status Bar)와 타이틀바(Title Bar)를 숨겨야 합니다. 숨기는 방법은 여러가지가 존재하는데 그 중 몇가지 방법을 정리하도록 하겠습니다.

http://www.androidpub.com/4710


Posted by Kelly Cook
,

http://rsequence.com/android_blog/

열심히 공부해서 우리모두 최고의 안드로이드 개발자가 됩시다. 웃쌰 . 웃쌰 .

Posted by Kelly Cook
,