'LayoutInflater'에 해당하는 글 1건

반응형

A.Activity 안에 A.fragment가 하나있고 그 A.fragment에서 다른 B.fragment를 호출한다.

A.fragment는 자동으로 A.Activity의 테마가 적용되어져 있다.

하지만 B.fragment는 A.Activity의 테마가 적용되어지지 않고 있다.

 

따라서 fragment 안에서 별도로 테마를 적용해 주어야한다.

 

아래처럼 onCreateView내의 inflater를 사용하였더니 테마적용이 되질않는다... ㅜㅜ

 

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {


Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.AppTheme_Base);
LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);

View v = localInflater.inflate(R.layout.fragment_work_detail, container, false);


return v;
}

 
 

그래서 getActivity().getLayoutInflater()를 호출하여 사용하니 적용이 잘된다.

 

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {


Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.AppTheme_Base);
LayoutInflater localInflater = getActivity().getLayoutInflater().cloneInContext(contextThemeWrapper);

View v = localInflater.inflate(R.layout.fragment_work_detail, container, false);


return v;
}
반응형

WRITTEN BY
아카이시

,