@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.tour_detail_info_fragment, container, false);
//TODO Create Layout
return view;
}
보통은 이런방식으로 fragment 의 view를 return 하는데. 간혹 FragmentTab 을 쓴다던지 할 때, 위 onCreateView를 실행해서 view 를 다시 그린다.그런 과정에서 infalteException 이 발생 할 수 있다.
그럴 때는 아래와 같이 view 를 전역에 두고 null 체크를 하자.
private View _rootView;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
if(_rootView == null)
{
_rootView = inflater.inflate(R.layout.tour_detail_info_fragment, container, false);
//CODE HERE
else
{
ViewGroup parent = ((ViewGroup)_rootView.getParent());
if(parent != null)
{
parent.removeView(_rootView);
}
}
return _rootView;
'안드로이드' 카테고리의 다른 글
| ViewPager 와 SwipeRefreshLayout (2) | 2015.01.19 |
|---|---|
| MODE_PRIVATE (0) | 2015.01.08 |
| TextView Font Size 코드 (0) | 2014.11.06 |
| InputStream > Byte Array (0) | 2014.07.17 |
| Bitmap Round (0) | 2014.06.05 |



