2011-07-04 7 views
0

Eclipse를 사용하여 사용자 정의 구성 요소 (MyTextView, android.widget.TextView)를 상속받은 간단한 Android 프로젝트를 만들었습니다. 내가 파일을 만든 후 는 아래 규정 된 나는,이 클래스에 속성을 추가 attrs.xml이 :Eclipse에서 사용자 정의 속성을 표시하지 않습니다. (attrs.xml)

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:mt="http://schemas.android.com/apk/res/myprogram.custom" 
    android:orientation="vertical" 
    android:layout_height="fill_parent" android:layout_width="fill_parent"> 
    <myprogram.custom.MyTextView 
     android:text="MyTextView" 
     android:id="@+id/myTextView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 
    </myprogram.custom.MyTextView> 
</LinearLayout> 
:

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <declare-styleable name="MyTextView" > 
     <attr name="AttributeOne" format="integer"/> 
    </declare-styleable> 
</resources> 

나는 나의 main.xml에에 선형 레이아웃 객체를 추가

main.xml을 열고 '그래픽 레이아웃'탭을 선택하여 내 구성 요소를 선택하면 사용자 정의 속성이 Eclipse의 '속성'탭에 나타나지 않지만 클래스 상속의 원래 특성 (android .widget.TextVie w)가 나타납니다.
이것은 실수였습니까? 내 맞춤 속성을 제출하는 절차는 무엇입니까? 아니면 오인입니까?

감사합니다. 루치아노.

+0

isInEditMode

if(!isInEditMode()) { // Your custom code that is not letting the Visual Editor draw properly // i.e. thread spawning or other things in the constructor } 

세부 사항? 프로젝트를 다시로드하지 않는 한 테마를 추가 할 때 Eclipse의 그래픽 레이아웃이 업데이트되지 않는 것으로 나타났습니다. – Gregory

+1

네, 그래도 작동하지 않습니다 ... – Luciano

답변

2

방금 ​​Eclipse를 다시 시작했습니다. : D

+1

예, 무슨 해결책! 다시 말하면, 잘못했다고 생각하면 코드를 무한대로 다시 할 수 있지만 환경을 다시 시작하기 만하면됩니다. 이것이 Eclipse의 모든 문제입니다. 존재하지 않는 버그로 작업 할 수 있습니다. – Deukalion

0

Android Developer Tools이보기와 상호 작용할 수있게하려면 최소한 ContextAttributeSet 개체를 매개 변수로 사용하는 생성자를 제공해야합니다. 이 생성자를 사용하면 레이아웃 편집기에서 뷰의 인스턴스를 만들고 편집 할 수 있습니다.

class PieChart extends View 
{ 
    public PieChart(Context context, AttributeSet attrs) 
    { 
     super(context, attrs); 
    } 
} 

또는 정지 후 해결되지 않을 경우 당신은 당신의 사용자 정의보기에이 작업을 수행 할 수 있습니다 다시 프로젝트 개방 닫을 시도해 봤어

관련 문제