-2
我想添加片段,我設置了前一個背景#ffffff佈局當我去下一個片段時隱藏,但是在之前片段中的項目在下一個片段中工作時,片段不能隱藏原因?以前的片段不隱藏爲什麼?
這是我的代碼
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if(isSearchHappened){
android.support.v4.app.FragmentTransaction transection=getActivity().getSupportFragmentManager().beginTransaction();
transection.hide(WorkOrderFragment.this);
DeliveryProcessFragment deliveryProcessFragment=new DeliveryProcessFragment();
deliveryProcessFragment.jobBeans = searchArayList.get(position);
transection.add(R.id.frame, deliveryProcessFragment);
transection.commit();
}else {
android.support.v4.app.FragmentTransaction transection=getActivity().getSupportFragmentManager().beginTransaction();
transection.hide(WorkOrderFragment.this);
DeliveryProcessFragment deliveryProcessFragment=new DeliveryProcessFragment();
deliveryProcessFragment.jobBeans = arrayList.get(position);
transection.add(R.id.frame, deliveryProcessFragment);
transection.commit();
}
}
});
'transection.add'不會從容器中刪除舊的片段。它增加了另一個之上的新的。要刪除以前,請使用'transection.replace' –
當我使用transaction.replace和比以前再次回來的片段,數據不顯示 –
這是另一個問題。 –