2012-10-30 5 views
0

Activity을 확장하는 클래스에서 Fragment까지 확장되는 intent을 시작하는 데 문제가 있습니다.Activity를 확장하는 클래스에서 단편을 확장하는 인 텐트를 시작하는 방법은 무엇입니까?

TabBar2.class -> 이것은 내가 내 의도를 작성하는 방법입니다 조각

을 확장 ->은

Favourite.class가 활동을 확장합니다.

Intent intent1 = new Intent(TabBar2.this, Favourite.class); 
startActivity(intent1); 

그러나 onClick 때 의도를 실행할 때 내 응용 프로그램이 중단됩니다. 내 로그 카트는

Unable to instantiate activity 
ComponentInfo{com.honey.test/com.honey.test.Favourite}: 
java.lang.ClassCastException: com.honey.test.Favourite 

내가 뭘 잘못 했습니까? 누군가가 이것을 해결하는 방법을 안내 할 수 있습니까? 당신이 조각 (즐겨 찾기)를 FragmentActivity를 작성하고 추가해야하므로

+0

확인 전화를 생 일'에 http : // stackoverflow.com/질문/9831728/시작 - 한 - 조각 - 비아 의도를-내-A-fragment' – Steve

답변

9
당신이 의도을 통해 조각을 호출 할 수 있기 때문이다

는, 조각은 만족하지 컨테이너 모든 조각의 FragmentActivity

전체의 한 부분이다 점에서, 다음

Intent intent1 = new Intent(TabBar2.this, SomeFragmentActivity.class); 
startActivity(intent1); 

A Fragment is a piece of an application's user interface or behavior that can be placed in an Activitymore information

+0

makin에게 감사드립니다. 나에게 분명해. :) –

+0

@hotveryspicy 좋은 답변 및 설명 ++ –

+0

자세히 설명해 드리겠습니다. –

관련 문제