fragment

FragmentManager와 ChildFragmentManager

허니컴(Honeycomb)부터 액티비티나 프레그먼트 안에 프레그먼트를 추가할 수 있다. 이 프레그먼트 객체를 관리하는 것이 FragmentManager다. 프레그먼트 전반에 대한 소개는 공식문서를 참고하고, 여기서는 종종 헷갈려하는 FragmentManager와 일명 ChildFragmentManager의 차이점에 대해서만 설명한다. 먼저 ChildFragmentManager라는 용어부터 짚고 넘어가자. ChildFragmentManager라는 클래스는 따로 없다.  대신, Activity.getFragmentManager()나 Fragment.getFragmentManager()에서 반환하면 FragmentManager(이하 FM), Fragment.getChildFragmentManager() 메소드에서 반환되는 FragmentManager 객체를 ChildFragmentManager(이하 CFM)라고 보통 부른다. FM과 CFM […]

FragmentManager와 ChildFragmentManager Read More »

Fragment의 onActivityResult로 결과 받기

안드로이드 어플리케이션은 컴포넌트로 구성된다. ActivityManager는 이름과 달리 (액티비티 사이가 아닌) 컴포넌트들 사이에 Intent 형태의 데이터를 주고 받을 수 있게 해준다. 특히, 액티비티 간 데이터를 주고 받을 때 용이하도록 액티비티는 startActivity(), startActivityForResult(), onActivityResult() 메소드를 제공한다. 이 메소드들은 프레그먼트에도 있는데, 여기서는 프레그먼트의 onActivityResult()에 대해 살펴보자. 결론부터 말하면, 프레그먼트의 onActivityResult()도 다른 액티비티에서 데이터를 받을 수 있다. 다른 특별한

Fragment의 onActivityResult로 결과 받기 Read More »

알듯 말듯한 안드로이드의 컴포넌트들

컴포넌트(Component) 액티비티, 서비스, 브로드캐스트 리시버, 컨텐츠 프로바이더를 안드로이드 4대 컴포넌트라 합니다. 4대 컴포넌트 중 컨텐츠 프로바이더는 인텐트로 실행하지 않습니다. 4대 컴포넌트 중 브로드캐스트 리시버는 AndroidManifest.xml에 등록하지 않고도 사용할 수 있으며, 이를 동적 브로드캐스트 리시버라 부릅니다. 동적 브로드캐스트 리시버는 선택이 아닌 필수로, 동적 브로드캐스트 리시버를 통해서만 수신할 수 있는 브로드캐스트가 있습니다. 4대 컴포넌트 중 가장 많이

알듯 말듯한 안드로이드의 컴포넌트들 Read More »

Caused by: java.lang.IllegalStateException: Fragment already active

Caused by: java.lang.IllegalStateException: Fragment already active at android.app.Fragment.setArguments(Fragment.java:696) … 위와 같은 에러가 난다면 setArguments()의 주석을 먼저 확인해보자. /** * Supply the construction arguments for this fragment. This can only * be called before the fragment has been attached to its activity; that * is, you should call it immediately after constructing the fragment. The *

Caused by: java.lang.IllegalStateException: Fragment already active Read More »