기존 컨트롤이 마음에 들기 만하면 재사용 가능한 컨트롤을 만들려고 노력하고 있으므로 속성이 필요하지 않으며 추가 할 필요가 없습니다.
"사용자 정의보기"를 레이아웃으로 끌 때 컨트롤이 시각적 편집기를 표시하기를 원합니다.
나는 간단합니다 View_TextSeek.xml 3 개의 다른 장소에서 사용하는 경우 "텍스트와 Seekbar"를 원할 때마다 다시 만들고 싶지 않은 예제 레이아웃 (예 : 나중에 ColorPicker). 또는 "TextView"와 "Seekbar"가 모두 제어됩니다.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/view_textseek_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:paddingLeft="15dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:text="@string/view_textseek_text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RelativeLayout
android:id="@+id/view_textseek_container_seekbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/view_textseek_text"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:paddingRight="10dp"
android:paddingBottom="5dp" >
<SeekBar
android:id="@+id/view_textseek_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:max="255"
android:progress="0" />
</RelativeLayout>
</RelativeLayout>
그리고 이것은 기본적으로 내 수업입니다.
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.RelativeLayout;
public class TextSeekView extends RelativeLayout
{
public TextSeekView(Context context) { super(context); init(context); }
public TextSeekView(Context context, AttributeSet attrs) { super(context, attrs); init(context); }
public TextSeekView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(context); }
protected void init(Context context)
{
if (!isInEditMode())
{
LayoutInflater layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layoutInflater.inflate(R.layout.view_textseek, this, true);
}
}
}
보시다시피, 나는 이미 기존의 여러 컨트롤을 "수집"하고 이들을 처리하기 위해 하나의 "보기"또는 "컨트롤"을 갖고 싶습니다. 편집자에 나타나지 않습니다.
아니면 "사용자 정의"뷰를 올바르게로드 할 수 있도록 환경을 다시 시작 해야하는 일부 유형의 바보 버그 때문입니까?
그리고 나는 다른 견해에 대한 특별한 속성이 필요하지 않습니다. 전혀 아무것도 없으며, 추가 할 때이 레이아웃이나 다른 레이아웃을 반복해서 보여줄 수 있기를 원합니다.
C#과 마찬가지로 컨트롤에 3 개의 텍스트 상자를 추가하면 매번 3 개의 텍스트 상자를 사용하기 때문입니다. 그런 다음 3 개의 텍스트 상자를 원할 때마다 양식에서 제어를 드래그하십시오.