2016-06-27 7 views
0

私はアクティビティでlistviewを持っていて、アイテムがクリックされたときにフラグメントを開きたいと思っています。そのために、私はFrameViewと一緒にFrameViewを使用しましたが、それはアクティビティに対してフラグメントクラスのオーバーラップを引き起こします。このソリューションを削除する方法はありますか?fragmenttransaction over listview

Activity's Listview Item Click code: 
 

 
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
 
      @Override 
 
      public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { 
 

 
      
 

 
       DetailsView details = new DetailsView(); 
 
       getSupportFragmentManager().beginTransaction().addToBackStack(null).add(R.id.frame, details).commit(); 
 
      } 
 
     });
activity layout: 
 

 
<?xml version="1.0" encoding="utf-8"?> 
 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 
    android:orientation="vertical" 
 
    android:layout_width="match_parent" 
 
    android:layout_height="match_parent"> 
 

 
    <com.baoyz.swipemenulistview.SwipeMenuListView 
 
    android:id="@+id/list" 
 
    android:layout_width="match_parent" 
 
    android:layout_height="match_parent" /> 
 

 

 
    <LinearLayout 
 
     android:layout_width="match_parent" 
 
     android:layout_height="match_parent"> 
 

 

 
     <FrameLayout 
 
      android:id="@+id/frame" 
 
      android:layout_width="match_parent" 
 
      android:layout_height="match_parent"/> 
 

 
    </LinearLayout> 
 

 
</RelativeLayout>

答えて

0

残念ながら、私はどちらも同じ結果を持っていることをチェックしました代わりに.add()

+0

FragmentManager.Replace()を使用してみてください。 @Alex。 – CodeAssasins