2013-06-13 37 views
0

這是通過XML佈局我的片段仍然是在UI

public class ListFrag extends SherlockFragment implements OnItemClickListener 
{ 
    Context c; 
    List<ReferalRow> referal_RowItems; 
    DoctorDaoImpl doctorDao; 
    DoctorServiceImpl service; 
    DoctorValidator doctorValidator; 
    View layoutView; 
    ListView doctoListView; 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
      Bundle savedInstanceState) { 
     layoutView = inflater.inflate(R.layout.activity_refer_mangmnt, null); 
     return layoutView; 
    } 

打開一個片段我的第一個片段,這是我activity_refer_mangmnt的.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    android:padding="5dp" > 

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:layout_weight="2" 

     android:padding="2dp"> 
    <ListView 
     android:id="@+id/listView_refer_list" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:dividerHeight="1dp" 
     android:divider="@android:color/black" 
     android:choiceMode="singleChoice" 
     android:listSelector="@drawable/list_selector" /> 
    </LinearLayout> 
<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:background="@drawable/rightpanel_back"> 
<fragment 
    android:id="@+id/detail_fragment" 
    android:tag="detailfrag" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    class="com.example.app1.DetailsFrag" /> 
</LinearLayout> 
`</LinearLayout> 

,這是我DetailFrag類

public class DetailsFrag extends SherlockFragment 
{ 
    ExpandableListView detailList; 
    TextView tvMessage; 
@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
     Bundle savedInstanceState) { 
    contentView = inflater.inflate(R.layout.activity_refer_view, null); 
    detailList = (ExpandableListView) contentView.findViewById(R.id.ep_detail_view); 
    tvMessage = (TextView)contentView.findViewById(R.id.tv_textView); 
    return contentView; 
} 
@Override 
public void onActivityCreated(Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 
    super.onActivityCreated(savedInstanceState); 
    if(id==0) 
    { 
     detailList.setVisibility(View.GONE); 
     tvMessage.setText("Click on the item on the left panel to view the details"); 
    } 
    else 
    { 
     detailList.setVisibility(View.VISIBLE); 
     tvMessage.setVisibility(View.GONE); 
} 

這是我的onItem click Lister in LIstFrag

FragmentTransaction ft = getFragmentManager().beginTransaction(); 
     Fragment lastFrag = getFragmentManager().findFragmentByTag("detailfrag"); 
     if(lastFrag!=null) 
     ft.remove(lastFrag); 
     Fragment fragment = Fragment.instantiate(c, DoctorDetailsFrag.class.getName(),arguments); 
     ft.replace(R.id.detail_fragment, fragment); 
     ft.commit(); 

我需要當我第一次想點擊列表中的我想消失,該郵件中的項目後顯示在右側面板中的消息。但是這裏的消息並沒有從片段中刪除。它顯示在新片段的背景中。它是?

回答