2010-12-14 10 views
0

私はEditTextから派生したカスタムビューを作成しています。xmlレイアウトでカスタムビューが見えなくなる

package com.woodshy.glucoXpert.DPass; 

//... 

public class DPassValuesEditActivity extends GenericScreenActivity { 

//... 

public static class DPassValuesEditField extends EditText { 
    protected String mDbFieldName; 


    public DPassValuesEditField(Context context) { 
     super(context); 
    } 

    public DPassValuesEditField(Context context, AttributeSet attrs) { 
     super(context, attrs); 

     TypedArray a = context.obtainStyledAttributes(attrs, 
       R.styleable.DPassValuesEditField); 

     CharSequence s = a 
       .getString(R.styleable.DPassValuesEditField_dbFieldName); 
     if (s != null) { 
      mDbFieldName = s.toString(); 
     } 

    } 

    //... 
} 
} 

のres/attrs.xmlファイル、次のようになります:

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <declare-styleable name="DPassValuesEditField"> 
     <attr name="dbFieldName" format="string" /> 
    </declare-styleable> 
</resources> 

私は、XMLレイアウトに私のカスタムビューを追加している:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res/com.woodshy.glucoXpert" 
    android:id="@+id/LinearLayout01" android:layout_width="fill_parent" 
    android:layout_height="fill_parent" android:orientation="vertical"> 
    <ScrollView android:layout_width="fill_parent" 
     android:layout_height="fill_parent" android:layout_gravity="center_vertical" 
     android:scrollbars="vertical"> 
     <RelativeLayout android:id="@+id/editFielsdLayout" 
      android:layout_height="fill_parent" android:layout_width="fill_parent" 
      android:clickable="true"> 
      <view 
       class="com.woodshy.glucoXpert.DPass.DPassValuesEditActivity$DPassValuesEditField" 
       android:id="@+id/edtWeight" android:layout_width="wrap_content" 
       android:layout_height="wrap_content" android:width="75px" 
       android:maxLines="1" android:layout_below="@+id/TextView01" 
       android:lines="1" android:gravity="center" android:imeOptions="flagNoExtractUi" 
       android:inputType="numberDecimal" android:maxLength="3" 
       app:dbFieldName="Weight"></view> 

     </RelativeLayout> 


    </ScrollView> 
</LinearLayout> 
を私の見解は、このような内部クラスとして宣言されています

私は視覚的なエディタ(Eclipse SDK、バージョン:3.6.1)でそれを見ることはできませんが、実行時にアプリケーションに現れ、うまくいきます。

何か間違っていますか?ビジュアルエディタでカスタムビューを表示するにはどうすればよいですか?

ありがとうございました。

答えて

-1

ビジュアルエディタでカスタムビューを表示するにはどうすればよいですか?

できません。

+3

クリスティアン、あなたの声明に関するリンクはありますか? AFAIK、カスタムビューが通常のクラス(内部クラスではない)として宣言されている場合、可視エディタで使用できます。それは目に見えます。 – woodshy

0

同じ問題がありました。 カスタムビューを表示するには、プラグインを再読み込みする必要があります。 グラフィカルレイアウトエディタでスイッチターゲットプラットフォームを現在のものから別のものに切り替えます(たとえば、2.1から2.3)。これは、「現在の」(例では2.1)に戻っても、カスタムビューを表示し続けます。

また、時折Eclipseを再起動する必要があります。

関連する問題