안드로이드 개발 질문/답변
(글 수 45,052)
보기쉽게 코드로 보여드릴게요. (많은 필요없는 부분은 생략했습니다)
public class A extends Activity {
flipper.addView(new B(A.this, year, month);
}
public class B {
cell.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(con, C.class); //con은 class A의 Context 입니다.
startActivity(intent);
}
});
}
위의 클래스 A의 flipper에다가 class B의 객체를 생성해 그 뷰를 추가합니다.
class B는 액티비티가 아닌 외부 클래스 인데요
클래스 B에서 onClick으로 클릭시에 다른 C라는 액티비티를 호출하고 싶습니다.
저런식으로 해주면 startActivity(intent)에서
The method startActivity(Intent) is undefined for the type B
이러한 오류가 납니다.
어떻게 하면 외부클래스에서 다른액티비티를 호출 할 수 있을까요?