2013-08-03 3 views
0

내 클래스 AsyncTask에서 확장 중이지만 다른 활동에서 전달 된 컨텍스트가 있습니다. 그래서 나는이 시도 :AsyncTask에서 ListView를 정의하는 방법은 무엇입니까?

 listview = (ListView) findViewById(R.id.listview1); 

오류 :이 또한 시도

The method findViewById(int) is undefined for the type loadSomeStuff 

:

 listview = (ListView) ctx.findViewById(R.id.listview1); 

오류 :

The method findViewById(int) is undefined for the type Context 

가 어떻게이 오류를 통해 얻을 수 있습니다 ?

답변

0

또는 Activity.findViewById()입니다. 내가 조각으로 캐스팅 무엇을 할 수

그렇게

listview = (ListView) ((Activity)ctx).findViewById(R.id.listview1); 

Source

+0

@MocialoveBoris를 시도? –

+0

@AndroidArabia 당신은 무엇을 의미합니까? "Activity"라고 입력했는데 조각에 –

+0

조각을 캐스팅 할 수 있습니다. 조각을 원합니다. 어떻게해야합니까 ??? @MacialovBoris –

관련 문제