Hello,

J'ai récupéré le menu de google plus qui utilise se code pour les fragment de page :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
	private void displayView(int position) {
		// update the main content by replacing fragments
		Fragment fragment = null;
		switch (position) {
		case 0:
            fragment = new HomeFragment();
			break;
		case 1:
			fragment = new SwissFragment();
			break;
		case 2:
			fragment = new FrenchFragment();
			break;
		case 3:
			fragment = new ChinaFragment();
			break;
		case 4:
			fragment = new USFragment();
			break;
		case 5:
			fragment = new UKFragment();
			break;
 
        case 6:
           fragment = new CallFragment();
                break;
 
        case 7:
            fragment = new FavFragment();
                break;
 
         case 8:
             fragment=new MapFragment();
                break;
 
          case 9:
                fragment=new EspFragment();
                break;
 
 
 
		default:
			break;
		}
Dans le HomeFragment j'utilise le code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
 
import com.test.urgencecall.fragment.FavoriteListFragment;
import com.test.urgencecall.fragment.ProductListFragment;
 
 
public class HomeFragment extends FragmentActivity {
 
    private Fragment contentFragment;
    ProductListFragment pdtListFragment;
    FavoriteListFragment favListFragment;
 
 
    public HomeFragment() {
    }
 
 
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
 
        View rootView = inflater.inflate(R.layout.fragment_home, container, false);
 
 
        //------------------
        //
        //Importation du code favori
        //
        //------------------
 
        FragmentManager fragmentManager = getSupportFragmentManager();
 
        if (savedInstanceState != null) {
            if (savedInstanceState.containsKey("content")) {
                String content = savedInstanceState.getString("content");
                if (content.equals(FavoriteListFragment.ARG_ITEM_ID)) {
                    if (fragmentManager.findFragmentByTag(FavoriteListFragment.ARG_ITEM_ID) != null) {
                        setFragmentTitle(R.string.favorites);
                        contentFragment = fragmentManager
                                .findFragmentByTag(FavoriteListFragment.ARG_ITEM_ID);
                    }
                }
            }
            if (fragmentManager.findFragmentByTag(ProductListFragment.ARG_ITEM_ID) != null) {
                pdtListFragment = (ProductListFragment) fragmentManager
                        .findFragmentByTag(ProductListFragment.ARG_ITEM_ID);
                contentFragment = pdtListFragment;
            }
        } else {
            pdtListFragment = new ProductListFragment();
            setFragmentTitle(R.string.app_name);
            switchContent(pdtListFragment, ProductListFragment.ARG_ITEM_ID);
        }
        return rootView;
    }
 
    @Override
    protected void onSaveInstanceState(Bundle outState) {
        if (contentFragment instanceof FavoriteListFragment) {
            outState.putString("content", FavoriteListFragment.ARG_ITEM_ID);
        } else {
            outState.putString("content", ProductListFragment.ARG_ITEM_ID);
        }
        super.onSaveInstanceState(outState);
    }
 
 
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
 
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.menu_favorites:
                setFragmentTitle(R.string.favorites);
                favListFragment = new FavoriteListFragment();
                switchContent(favListFragment, FavoriteListFragment.ARG_ITEM_ID);
 
                return true;
        }
        return super.onOptionsItemSelected(item);
    }
 
    public void switchContent(Fragment fragment, String tag) {
        FragmentManager fragmentManager = getSupportFragmentManager();
        while (fragmentManager.popBackStackImmediate()) ;
 
        if (fragment != null) {
            FragmentTransaction transaction = fragmentManager
                    .beginTransaction();
            transaction.replace(R.id.frame_container, fragment, tag);
            //Only FavoriteListFragment is added to the back stack.
            if (!(fragment instanceof ProductListFragment)) {
                transaction.addToBackStack(tag);
            }
            transaction.commit();
            contentFragment = fragment;
        }
    }
 
    protected void setFragmentTitle(int resourseId) {
        setTitle(resourseId);
        getActionBar().setTitle(resourseId);
 
    }
 
    /*
     * We call super.onBackPressed(); when the stack entry count is > 0. if it
     * is instanceof ProductListFragment or if the stack entry count is == 0, then
     * we finish the activity.
     * In other words, from ProductListFragment on back press it quits the app.
     */
    @Override
    public void onBackPressed() {
        FragmentManager fm = getSupportFragmentManager();
        if (fm.getBackStackEntryCount() > 0) {
            super.onBackPressed();
        } else if (contentFragment instanceof ProductListFragment
                || fm.getBackStackEntryCount() == 0) {
            finish();
        }
    }
 
    //---------------------
    //
    //Fin de l'importation
    //
    //---------------------
 
 
}
Dans les import il n'y a pas le android.app.framgent, ce qui pose problème au menu, je ovulais savoir il y yvait possibilité de mettre tous mes fragment avec android.support.v4.app.Framgent
Sachant que le code d'une page normale est :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package com.test.urgencecall;
 
import android.app.Fragment;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import com.test.urgencecall.R;
 
 
public class FrenchFragment extends Fragment {
 
    private Button button;
    private Button buttonamb;
    private Button buttonpolice;
 
    public FrenchFragment(){}
 
 
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
 
        View rootView = inflater.inflate(R.layout.fragment_french, container, false);
 
        //appele pour les pompiers
        button = (Button) rootView.findViewById(R.id.dial);
        button.setOnClickListener(new View.OnClickListener() {
 
            @Override
            public void onClick(View arg0) {
 
                Intent callIntent = new Intent(Intent.ACTION_CALL);
                callIntent.setData(Uri.parse("tel:18"));
                startActivity(callIntent);
 
            }
 
        });
 
 
        //appele pour l'ambulance
        buttonamb = (Button) rootView.findViewById(R.id.dialamb);
        buttonamb.setOnClickListener(new View.OnClickListener() {
 
            @Override
            public void onClick(View arg0) {
 
                Intent callIntent = new Intent(Intent.ACTION_CALL);
                callIntent.setData(Uri.parse("tel:15"));
                startActivity(callIntent);
 
            }
 
        });
 
 
 
        //Appele pour la police
        buttonpolice = (Button) rootView.findViewById(R.id.dialpolice);
        buttonpolice.setOnClickListener(new View.OnClickListener() {
 
            @Override
            public void onClick(View arg0) {
 
                Intent callIntent = new Intent(Intent.ACTION_CALL);
                callIntent.setData(Uri.parse("tel:17"));
                startActivity(callIntent);
 
            }
 
        });
 
        return rootView;
    }
}
Merci d'avance.