2011-08-25 4 views
1

EditText에 대한 사용자 지정 Attribut testAttribute를 정의하고 레이아웃에 적용했습니다. 이것은 예상대로 컴파일되므로 사용 가능하다고 생각합니다.표준보기에 대한 사용자 지정 특성 검색

<EditText android:layout_width="wrap_content" 
cst:testAttribute="true" 
android:layout_height="wrap_content"></EditText> 

알고 계시다면, 필자는 어떻게 동작하는지 프로그래밍 방식으로 testAttribute를 읽어야합니다. 사용자 정의보기에서이를 수행하는 방법을 알고 있지만 표준보기에서 필요합니다.

누구나 아이디어가 있으십니까? 사용자 정의보기에

답변

-1

다음을 수행 :

public MyCustomView(Context context, AttributeSet attrs, int defStyle) { 
      super(context, attrs, defStyle); 

      final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MyCustomView, defStyle, 0); 
      // the default value is true 
      // get the custom value progammatically 
      testAttribute = a.getBoolean(R.styleable.MyCustomView_testAttribute, true); 

      // make sure to recycle 
      a.recycle(); 
    } 

이 전혀 질문에 대답하지 않는 것이

+0

도움 희망 – Jeremy

관련 문제