2012-05-28 5 views
0

hey les gars que je cherche à faire un fragment du mobile lors de l'exécution afin que je puisse travailler sur d'autres fragments en gardant aside.following est mon main.xmlcomment faire des fragments mobiles dans l'exécution

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

// ce fragment doit être mobile

<LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_weight="0.95" 
     android:orientation="vertical" > 

     <fragment 
      android:id="@+id/fragment2" 
      android:name="com.harshal.fragments.Fragment2" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="11.02" > 

      <!-- Preview: [email protected]/fragment2 --> 
     </fragment> 

     <fragment 
      android:id="@+id/fragment3" 
      android:name="com.harshal.fragments.Fragment3" 
      android:layout_width="fill_parent" 
      android:layout_height="373dp" 
      android:layout_weight="1" > 

      <!-- Preview: [email protected]/mainchart --> 
     </fragment> 

    </LinearLayout> 

</LinearLayout> 
+0

veuillez effacer votre question. – kyogs

+0

ce que vous voulez? Vous voulez changer fragment2 en fragment3 ... ??? – kyogs

+0

désolé pour la confusion je veux rendre l'utilisateur capable d'échanger les positions des deux fragments dans l'exécution, c'est-à-dire fragment1 au fragment2 et fragment2 au fragment1 –

Répondre

0
private void stackAFragmentPresc() { 
      // TODO Auto-generated method stub 
      Fragment f; 
      f = new PrescribeFragment(); 
      FragmentTransaction ft = getFragmentManager().beginTransaction(); 
      ft.replace(R.id.main_details_fragment_container, f); 
      ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); 
      ft.addToBackStack(null); 
      ft.commit(); 
     } 

essayer avec ce code, ici PrescribeFragment() est votre classe de fragmnet. et (main_details_fragment_container) celui-ci est votre identifiant en XML. J'espère que cela vous sera utile. merci

Questions connexes