마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

attrs커스텀뷰에 적용시키고 사용하는 문제.. [closed]

0 추천
no resource identifier found for attribute ~ in package 'myapp'라는 문구가 계속나옵니다..

라이브러리가아닌자체 리소스에서에러가 나서 이렇게 질문합니다.

그냥커스텀뷰를만들어서사용하려고하는데이상하게 되는것이 있고안되는것들이있네요 ...;;

소스는

attires.xml에

<declare-styleable name="lwc_ImageView">

    <attr format="float" name="lwc_iv_Width"/>

    <attr format="float" name="lwc_iv_Height"/>

    <attr format="boolean" name="lwc_iv_Stroke"/>

    <attr format="boolean" name="lwc_iv_Margin_Layout"/>

    <attr formay="reference|integer" name="lwc_iv_Margin_top"/>

    <attr formay="reference|integer" name="lwc_iv_Margin_bottom"/>

    <attr formay="reference|integer" name="lwc_iv_Margin_right"/>

    <attr formay="reference|integer" name="lwc_iv_Margin_left"/>

</declare-styleable>

이렇게 정의해주었구요

커스텀뷰에서

public lwc_ImageView(Context context, AttributeSet attrs) {

      super(context, attrs);

      initView(context,attrs);

   }

   

   public lwc_ImageView(Context context, AttributeSet attrs, int defStyleAttr) {

      super(context, attrs, defStyleAttr);

      initView(context,attrs);

   }

 

// public lwc_ImageView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {

//    super(context, attrs, defStyleAttr, defStyleRes);

//    initView(context,attrs);

// }

   

   private void initView(Context context, AttributeSet attrs) {

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

      stroke = a.getBoolean(R.styleable.lwc_ImageView_lwc_iv_Stroke,false);

      lwc_width = a.getFloat(R.styleable.lwc_ImageView_lwc_iv_Width,0.0f);

      lwc_height = a.getFloat(R.styleable.lwc_ImageView_lwc_iv_Height,0.0f);

      lwc_margin_top = a.getInteger(R.styleable.lwc_ImageView_lwc_iv_Margin_top,0);

      lwc_margin_bottom = a.getInteger(R.styleable.lwc_ImageView_lwc_iv_Margin_bottom,0);

      lwc_margin_left = a.getInteger(R.styleable.lwc_ImageView_lwc_iv_Margin_left,0);

      lwc_margin_right = a.getInteger(R.styleable.lwc_ImageView_lwc_iv_Margin_right,0);

      lwc_margin_layout = a.getBoolean(R.styleable.lwc_ImageView_lwc_iv_Margin_Layout, true);

   }

이렇게 적용시키고

 

사용하고싶은 xml에서

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

              xmlns:app="http://schemas.android.com/apk/res-auto"

              android:layout_width="match_parent"

              android:layout_height="match_parent"

              android:gravity="bottom"

              android:orientation="vertical">

 

    <secuway.ubody.health.u_body.Lwc_CustomView.lwc_ImageView

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        app:lwc_iv_Margin_Layout="true"

        app:lwc_iv_Margin_top="30"

        android:id="@+id/img"

        app:lwc_iv_Height="23"

        app:lwc_iv_Stroke="true"

        app:lwc_iv_Width="22"/>

 

    <secuway.ubody.health.u_body.Lwc_CustomView.lwc_TextView

        android:id="@+id/tv"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:textColor="@android:color/white"

        app:lwc_tv_Margin_Layout="true"

        app:lwc_tv_Margin_left="10"

        app:lwc_tv_TextSize="12"/>

 

</LinearLayout>

이렇게해주었는데이상한점이

/Users/lwc/Desktop/work/trainer/U_Body/app/src/main/res/layout/custom_main_calendar_category_object.xml

Error:(9) No resource identifier found for attribute 'lwc_iv_Margin_top' in package 'secuway.ubody.health.u_body'

Error:(19) No resource identifier found for attribute 'lwc_tv_Margin_left' in package 'secuway.ubody.health.u_body'

Error:(19) No resource identifier found for attribute 'lwc_tv_TextSize' in package 'secuway.ubody.health.u_body'

/Users/lwc/Desktop/work/trainer/U_Body/app/src/main/res/layout/mainfragment_activity.xml

Error:(17) No resource identifier found for attribute 'lwc_iv_Margin_top' in package 'secuway.ubody.health.u_body'

/Users/lwc/Desktop/work/trainer/U_Body/app/build/intermediates/res/merged/debug/layout/custom_main_calendar_category_object.xml

Error:(9) No resource identifier found for attribute 'lwc_iv_Margin_top' in package 'secuway.ubody.health.u_body'

Error:(19) No resource identifier found for attribute 'lwc_tv_Margin_left' in package 'secuway.ubody.health.u_body'

Error:(19) No resource identifier found for attribute 'lwc_tv_TextSize' in package 'secuway.ubody.health.u_body'

 

에러가이런식으로  나는데. 보시면. 에러가 안나는 리소스도있는데  왜이러는거죠?.....  클린  컴퓨터재부팅 다 해보았습니다..
질문을 종료한 이유: 해결하였습니다...; 오타였네요 ...;
니쿠네임이다 (520 포인트) 님이 2017년 2월 6일 질문
니쿠네임이다님이 2017년 2월 7일 closed

1개의 답변

0 추천


    <attr format="boolean" name="lwc_iv_Margin_Layout"/>

이건 포맷이고
    <attr formay="reference|integer" name="lwc_iv_Margin_top"/>

이건 포메이네요 ㅋ

익명사용자 님이 2017년 2월 7일 답변
...아... 되네요.......;;;;;;;;  ㅜㅜ 후... 감사합니다..
...