-1
먼저 레이아웃을 설명하고 싶습니다. 이것은 "탭의 탭 목록"입니다. 이는 목록보기가 탭에 의해 제어되고 탭 목록이 다른 탭에 의해 제어됨을 의미합니다."지정한 자식이 이미 부모가 있습니다. 조각을 바꿀 때 먼저 자식의 부모에서 removeView()를 호출해야합니다"
(하단 탭 : 메인 컨트롤 패널)
public class BottomTabWidget extends FragmentActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bottom_tab);
FragmentTabHost tabHost = (FragmentTabHost)findViewById(R.id.bottom_tab_host);
tabHost.setup(this, getSupportFragmentManager(), R.id.bottom_tab_content);
View exploreView = LayoutInflater.from(this).inflate(R.layout.explore, null);
View browseView = LayoutInflater.from(this).inflate(R.layout.browse, null);
View profileView = LayoutInflater.from(this).inflate(R.layout.profile, null);
View cartView = LayoutInflater.from(this).inflate(R.layout.cart, null);
tabHost.addTab(tabHost.newTabSpec("explore").setIndicator(exploreView), ListTabWidget.class, null);
tabHost.addTab(tabHost.newTabSpec("browse").setIndicator(browseView), SearchList.class, null);
tabHost.addTab(tabHost.newTabSpec("profile").setIndicator(profileView), SearchList.class, null);
tabHost.addTab(tabHost.newTabSpec("cart").setIndicator(cartView), SearchList.class, null);
}
}
내 두 개의 탭 위젯 ... 당신이 무슨 뜻인지 이해할 수 있기를 바랍니다 (목록 탭 : 목록 만보기를 제어)
public class ListTabWidget extends Fragment{
//for extending Fragment
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedIntanceState){
//View view = inflater.inflate(R.layout.list_tab, container);
//FragmentTabHost tabHost = (FragmentTabHost)view.findViewById(R.id.list_tab_host);
FragmentTabHost tabHost = new FragmentTabHost(getActivity());
tabHost.setup(getActivity(), getChildFragmentManager(), R.id.listtabcontent);
View tabView = setTab(inflater, " New Items ");
tabHost.addTab(tabHost.newTabSpec("all_post").setIndicator(tabView), ListPost.class, null);
return tabHost;
}
private View setTab(LayoutInflater inflater, String text){
View tabView = inflater.inflate(R.layout.list_tab_text, null);
TextView textView = (TextView)tabView.findViewById(R.id.textView);
textView.setText(text);
return tabView;
}
}
코드 ListPost
클래스 (너무 오래 그래서이 중요한 부분을 잘라)
FragmentProcess
클래스
public class FragmentProcess {
public void switchFragment(FragmentActivity activity, int element, Fragment replaceFragment, Bundle args){
replaceFragment.setArguments(args);
FragmentTransaction transaction = activity.getSupportFragmentManager().beginTransaction();
transaction.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
transaction.replace(element, replaceFragment);
transaction.addToBackStack(null);
transaction.commit();
}
}
오류가 발생한다. 내가 뭘 잘못 했니?