ViewPager dans un fragment
Bonjour,
Pour l'instant ce que je montre depuis ma fragment list sont de simple layouts, par :
Code:
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
| @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
String curPage = getArguments().getString(ARG_ITEM_ID);
View rootView;
if(curPage.equals("1")) {
rootView=inflater.inflate(R.layout.fragment_item_detail1, container, false);
} else if (curPage.equals("2")) {
rootView=inflater.inflate(R.layout.conf_activity, container, false);
} else if (curPage.equals("3")) {
rootView=inflater.inflate(R.layout.fragment_item_detail3, container, false);
} else if (curPage.equals("4")) {
rootView=inflater.inflate(R.layout.fragment_item_detail4, container, false);
} else {
rootView=inflater.inflate(R.layout.fragment_item_detail5, container, false);
TextView t1 = (TextView) rootView.findViewById(R.id.acces_addr_isfa);
t1.setMovementMethod(LinkMovementMethod.getInstance());
TextView t2 = (TextView) rootView.findViewById(R.id.acces_addr_gala);
t2.setMovementMethod(LinkMovementMethod.getInstance());
final Button goIsfa = (Button) rootView.findViewById(R.id.button_isfa);
goIsfa.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Uri location1 = Uri.parse("geo:0,0?q=50+avenue+Tony+Garnier,+69007+Lyon");
Intent intent1 = new Intent(Intent.ACTION_VIEW, location1);
String title = "Choisissez votre app de navigation préférée";
// Create and start the chooser
startActivity(Intent.createChooser(intent1, title));
}
});
final Button goGala = (Button) rootView.findViewById(R.id.button_gala);
goGala.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Uri location2 = Uri.parse("geo:0,0?q=Les+Terrasses+du+Parc,+115+bd+Stalingrad,+69100+Villeurbanne");
Intent intent2 = new Intent(Intent.ACTION_VIEW, location2);
String title = "Choisissez votre app de navigation préférée";
// Create and start the chooser
startActivity(Intent.createChooser(intent2, title));
}
});
}
return rootView;
} |
Seulement voilà, j'aimerais bien insérer un ViawPager, défini par un FragmentActivity à la place d'un simple layout.
En mode portrait ça se pase très bien par un intent, mais en mode paysage... je sèche.
J'avais dans l'idée de faire :
Code:
1 2 3 4 5 6
| if(id.equals("2")) {
ConfActivity fragment = new ConfActivity();
getSupportFragmentManager().beginTransaction()
.replace(R.id.item_detail_container, fragment)
.commit();
} |
Dans le .itemSelected de ma FragmentActivity, mais vu que fragment est une FragmentActivity, ça ne fonctionne pas.
D'avance merci !