1. 사용자 컨트롤 .java 파일입니다.
package com.lni.CustomPasteTest;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
public class CustomControl extends LinearLayout {
public CustomControl(Context context) {
super(context);
// TODO Auto-generated constructor stub
//레이아웃의 방향을 수직으로 설정한다.
LayoutInflater inflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.customcon, this);
}
public CustomControl(final Context context, AttributeSet attrs) {
super(context,attrs);
LayoutInflater inflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.customcon, this);
}
}
인터페이스 xml 입니다.
<merge
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</merge>
2. main.xml 에서 com.lni.CustomControl 을 추가시켰습니다.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<com.lni.CustomControl
android:id="@+id/CustomControl"
android:layout_width = "fill_parent"
android:layout_height = "fill_parent"
/>
</LinearLayout>
결과는 실행이 안됩니다. 다른 분들꺼 보니 이렇게 하면 된거 같은데 저는 죽어도 안되네요. ㅠㅠ 도와주세염....