2013-07-04 3 views
0

LayoutInflater vi = (LayoutInflater) getSystemService (Context.LAYOUT_INFLATER_SERVICE);getSystemService() 메서드가 인식되지 않습니다.

내가 복용하고, 사용 getSystemService() 만하고 오류

getSystemService 또는 기타 솔루션 대신 사용하는 어떤

"방법 getSystemService (문자열) 유형 CustomAdapter에 대한 정의되지?"

답변

0
LayoutInflater vi = (LayoutInflater) YourEnclosingActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
+0

불행히도 작동하지 않습니다. – erdemgc

+0

참조, getSystemService 메소드는 컨텍스트의 메소드입니다. 따라서 CustomAdapter에서 Activity의 컨텍스트를 가져와야합니다. 어댑터가 다른 파일에 있거나 중첩 된 정적 클래스 인 경우 생성자에서이를 전달하십시오. –

1

해당

public CustomAdapter(YourActivtyName context) { 

    LayoutInflater vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    } 
0

같은 어댑터이

위해 LayoutInflater VI = (LayoutInflater에서) YourClassName.this.getSystemService (Context.LAYOUT_INFLATER_SERVICE)을 시도 할 수 있습니다;

또는

LayoutInflater에서 VI = (LayoutInflater에서) context.getSystemService (Context.LAYOUT_INFLATER_SERVICE);

여기서 context는 Context 클래스의 객체입니다.

관련 문제