bjr a tt le monde
j'utilise dans mon projet android le scrolling d'un page a une autre avec pageview
et des fragments

mon problème est comment srcollé d'un fragment a un autre manuellement sans la glusse avec le doit

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
public class PagePrincipaleActivity extends FragmentActivity {
 
	//mes 2 adaptateur pour le groupe et la page
	private ViewPager _mViewPager;
	private ViewPagerAdapter _adapter;
	private ActionBar actionBar;
    InfoAction faction=new InfoAction();
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
 
       actionBar = (ActionBar) findViewById(R.id.actionbar);
       //sethome action pour que l'icone du home soit 3al lawwel 
       actionBar.setHomeAction(faction);
       //setdisplayhomeAsEnable pour le fleche en hautttt
       actionBar.setTitle("Diabetes Control");
       final Action AbautAction = new IntentAction(this, new Intent(this, SettingActivity.class), R.drawable.calculator);
       actionBar.addAction(AbautAction);
 
       final Action otherAction = new IntentAction(this, new Intent(this, SettingActivity.class), R.drawable.setting);
       actionBar.addAction(otherAction);
 
 
       //ajouter une icone avec action
      //final Action ConfigAction = new ConfigAction(); 
       //ajouter l'action a l'action bar
       //actionBar.addAction(ConfigAction);
 
 
 
 
        setUpView();
        setTab();
    }
 
    public static Intent createIntent(Context context) {
        Intent i = new Intent(context, PagePrincipaleActivity.class);
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        return i;
    }
 
 
    @Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
	finish();
        }
 
 
    private void setUpView(){    
 
    //on ajoute l'adaptateur au pageview
   	 _mViewPager = (ViewPager) findViewById(R.id.viewPager);
     _adapter = new ViewPagerAdapter(getApplicationContext(),getSupportFragmentManager());
     _mViewPager.setAdapter(_adapter);
    //on initialise le fragment numero 0 ou premier comme page principale de notre projet
    //ou je vais mettre mon menu principale
	 _mViewPager.setCurrentItem(0);
    }
 
 
    //quand le tab change on joue avec la visiblité des fragment
    //peut etre nzidou fragment e5er pour les inforamtions sur les antioxydant
    private void setTab(){
			_mViewPager.setOnPageChangeListener(new OnPageChangeListener(){
 
						@Override
						public void onPageScrollStateChanged(int position) {}
						@Override
						public void onPageScrolled(int arg0, float arg1, int arg2) {}
						@Override
						public void onPageSelected(int position) {
							// TODO Auto-generated method stub
							switch(position){
							case 0:
 
 
								break;
 
 
							case 1:
 
 
								break;
 
							case 2:
 
								break;
 
 
							case 3:
 
								break;
							}
						}
 
					});
 
    }
 
        @Override
        public void performAction(View view) {
            //Toast.makeText(PagePrincipaleActivity.this,"Example action", Toast.LENGTH_SHORT).show();
            findViewById(R.id.first_tab).setVisibility(View.VISIBLE);
			findViewById(R.id.second_tab).setVisibility(View.INVISIBLE);
			findViewById(R.id.troisieme_tab).setVisibility(View.INVISIBLE);
			 //on rev1 a la page du fragment principale
			_mViewPager.setCurrentItem(0);
        }
 
    }
 
 
}


j'utilise _mViewPager.setCurrentItem(0); pour mettre le fragment 1 par defaut
comment je peut l'utilise dans mon fragment avec ce 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
 
 
package com.manishkpr.viewpager;
 
import com.manishkpr.viewpager.R;
import com.yassin.add.GlucoseReadinggActivity;
 
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Toast;
 
public class LayoutMenu extends Fragment {
	Button x1,x2,x3,x4;
 
	public static Fragment newInstance(Context context) {
		LayoutMenu f = new LayoutMenu();	
 
		return f;
	}
 
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
		ViewGroup root = (ViewGroup) inflater.inflate(R.layout.layout_menu, null);		
		return root;
	}
 
	@Override
	public void onStart()
	{
		super.onStart();
 
 
 
	}
 
 
	 public void initcontroll()
	 {
		 x1 = (Button)getView().findViewById(R.id.buttonx1);
		 x1.setOnClickListener(new OnClickListener() {
 
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				//je veut mettre le code pour allé a un autre fragment de ma pageview
 
 
			}
		});
 
	 }
 
}