2017-12-28 25 views
2

POJO 모델을 만들고 호출하지 않았습니다.모델에서 데이터를 가져올 수 없습니다.

실행 코드입니다.

DataObjectSelectGarage selectGarage = ...; 
TextView.setText(selectGarage.getGaragename()); 

이렇게하면 실행할 수 있는지 모르겠습니까?

이 모델

public class DataObjectSelectGarage implements Serializable { 
    @SerializedName("Garage_id") 
    private int id; 

    public int getGarage_id() { 
    return id; 
    } 

    public void setgetGarage_id(String getGarage_id) { 
    this.id = id; 
    } 

    @SerializedName("Garagename") 
    private String name; 

    public String getGaragename() { 
    return name; 
    } 

    public void setGaragename(String name) { 
    this.name = name; 
    } 
} 
+0

당신은 당신의 oncreate에서 그것을 initalize 했습니까? selectGarage = new DataObjectSelectGarage(); – DroiDev

답변

0
public void setgetGarage_id(String getGarage_id) { 
    this.id = id; 
    } 

대신 ID 이드 = ID를 할당하는 상기 설정 방법은 = getGarage_id

0

이 이러한 방식으로 작동 할 수는

DataObjectSelectGarage로서
DataObjectSelectGarage selectGarage; 

TextView.setText(selectGarage.getGaragename()); 

는 없다 초기화 됨. 먼저 초기화해야합니다.

두 번째로 게시 한 코드에는 값을 할당하지 않고 UserId를 HTTP 요청 매개 변수에 전달하는 것과 같은 여러 논리적 버그가 있습니다. 둘째로 사용자에게 응답하려고 애 쓰지 않고

@Override 
public void onResponse(String response) { 
/*DataObjectSelectGarage dataObjectSelectGarage = new 
DataObjectSelectGarage(); 
String test1 = dataObjectSelectGarage.getGaragename();*/ 
tvTest.setText(selectGarage.getGaragename()); 
Log.d("Selectgarage",response.toString()); 
} 

응답 문자열을 구문 분석 한 다음 모델 개체 및 설정 값을 초기화 한 후에보기를 사용하여 데이터를 표시해야합니다.