티스토리 뷰

이번에도 또 DataBinding입니다. 헤헤

 

분명 DataBinding 예시를 보면서 따라했을 때는 잘 됐는데, 내 프로젝트 아이템들을 RecyclerView의 아이템 row에 넣으려고 할 때는 대체 왜 안될까 뭐가 문젤까!! 이러면서 머리를 쥐어뜯었어요.

 

대체 왜 identifier를 못 찾는거야 이유가 뭐야!! stackoverflow를 봐도 cannot find symbol 오류만 나와있었어요.

 

문제가 된 layout xml 파일과 item 입니다.

<layout>
    <data>
        <variable
            name="place"
            type="com.example.coditplace2.dto.ItemData"/>
    </data>

...
            <TextView
                android:id="@+id/tv_visit"
                android:text="@{place.pVisit}"
                android:textColor="@color/white"
                android:layout_marginTop="10dp"

 

import java.util.ArrayList;

public class ItemData {
    String pIdx;
    String pName;
    String pImage;
    String pVisit;
    String pIcon;
    String pCategory;
    String pPhone;
    String pContent;
    String pLike;

    public ItemData(String pIdx, String pName, String pImage, String pVisit, String pIcon, String pCategory, String pPhone, String pContent, String pLike) {
        this.pIdx = pIdx;
        this.pName = pName;
        this.pImage = pImage;
        this.pVisit = pVisit;
        this.pIcon = pIcon;
        this.pCategory = pCategory;
        this.pPhone = pPhone;
        this.pContent = pContent;
        this.pLike = pLike;
    }
...

 

 

당췌 암만 봐도 모르겠다 이겁니다. 대체 왜그러는거야!! 정말 노트북 엎을 뻔 했습니다.

멀쩡하게 있는 애를 왜 자꾸 없다하냐구요.. 존재를 부정해버리네..

 

 

힌트는 생각지도 못한 곳에 있었어요.

https://kesio.tistory.com/31

 

이분은 variable의 name을 변경하셨더라구요.

그래서 바꿔봤는데 전혀 소용이 없었어요. 

애초에 난 언더바 쓰지도 않았다고!!!

 

근데, 가만히 생각해보니까 이름 하나가지고도 저렇게 까탈스러운 애들이면, item에 넣을 변수 이름 가지고도 까탈스럽지 않을까? 그래서 item 변수들 이름을 다 바꿔봤어요 소문자로!!

사실 정말 말도 안되는 전개죠... 그런데...

 

 

 

진짜 이러면 안되는 거 아닙니까..,?

아니 변수 이름 중간에 대문자 껴있다고 데이터결합 안시켜주는게 어딨어

 

소문자 천국으로 리모델링한ItemData.java 클래스

public class ItemData {
    String pidx;
    String pname;
    String pimage;
    String pvisit;
    String picon;
    String pcategory;
    String pphone;
    String pcontent;
    String plike;

    public ItemData(String pidx, String pname, String pimage, String pvisit, String picon, String pcategory, String pphone, String pcontent, String plike) {
        this.pidx = pidx;
        this.pname = pname;
        this.pimage = pimage;
        this.pvisit = pvisit;
        this.picon = picon;
        this.pcategory = pcategory;
        this.pphone = pphone;
        this.pcontent = pcontent;
        this.plike = plike;
    }

 

결과는?!!!



너무 당연하게 finding 해옵니다... identifier.... 이놈들... 괘씸해...

 

오늘의 요약 : DataBinding에 쓰는 변수 이름은 꼭 소문자로!!!

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함