note

android 기본 본문

Android/기본

android 기본

투한 2012. 1. 5. 14:55
package com.android.textview3;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import android.graphics.Color;

public class TextViewDemo3 extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        //main.xml 등록
        setContentView(R.layout.main);
        
        //사전에 등록한 id를 통해 Textview 객체 호출
        TextView text = (TextView)findViewById(R.id.text);
        text.setBackgroundColor(Color.GRAY);
        text.setTextColor(Color.WHITE);
        
    }
}


/* AUTO-GENERATED FILE.  DO NOT MODIFY.
 *
 * This class was automatically generated by the
 * aapt tool from the resource data it found.  It
 * should not be modified by hand.
 */

package com.android.textview3;

public final class R {
    public static final class attr {
    }
    public static final class drawable {
        public static final int ic_launcher=0x7f020000;
    }
    public static final class id {
        public static final int text=0x7f050000;
    }
    public static final class layout {
        public static final int main=0x7f030000;
    }
    public static final class string {
        public static final int app_name=0x7f040001;
        public static final int hello=0x7f040000;
    }
}



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

    <TextView
        android:id="@+id/text"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

</LinearLayout>





    Hello World, TextViewDemo3!
    03TextViewDemo3




'Android > 기본' 카테고리의 다른 글

Android 필드 박스  (0) 2012.01.05
Android 이미지 넣기  (0) 2012.01.05
Android 간단한 이벤트 3  (0) 2012.01.05
Android 간단한 이벤트2  (0) 2012.01.05
Android 간단한 이벤트  (0) 2012.01.05