DevAndroid Posted August 24, 2010 Share Posted August 24, 2010 Salut, J'aimerais savoir comment je peux scroller verticalement mon layout que j"ai creé sans XML?? Merci d'avance. Link to comment Share on other sites More sharing options...
eephyne Posted August 25, 2010 Share Posted August 25, 2010 si tu pouvais en xml et pas en le faisant en java , c'est que tu ne l'as pas reproduis exactement de la même manière Link to comment Share on other sites More sharing options...
DevAndroid Posted August 25, 2010 Author Share Posted August 25, 2010 Euh ok ... mais le probleme c'est que je ne sais pas comment faire ce n'est pas un probleme de reproduction. voila mon layout en Java avec un bouton: TableLayout continu = new TableLayout (this); continu.setOrientation(TableLayout.VERTICAL); Button bouton1 = new Button (this); continu.addView(bouton1); setContentView(continu); bouton1.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent intent = new Intent (continu.this, enigmes.class); startActivity(intent); } }); Je voudrais qu'il soit scrollable verticalement. merci Link to comment Share on other sites More sharing options...
Alocaly Posted August 25, 2010 Share Posted August 25, 2010 Rajoute un scrollview en code, non ? J'ai pas testé, mais c'est ce que j'essayerais ! Emmanuel / Alocaly Link to comment Share on other sites More sharing options...
DevAndroid Posted August 25, 2010 Author Share Posted August 25, 2010 Comme sa: TableLayout continu = new TableLayout (this); continu.setOrientation(TableLayout.VERTICAL); ScrollView scroll = new ScrollView(this); continu.addView(scroll); setContentView(continu); Button bouton1 = new Button (this); continu.addView(bouton1); setContentView(continu); bouton1.setText(""); bouton1.setVisibility(bouton1.GONE); bouton1.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent intent = new Intent (continu.this, enigmes.class); startActivity(intent); } }); Ca ne marche pas Link to comment Share on other sites More sharing options...
Random Posted August 26, 2010 Share Posted August 26, 2010 Pour se servir de ScrollView on met les Layout dedans, pas l'inverse ;) public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TableLayout table = new TableLayout(this); ScrollView scroll = new ScrollView(this); for(int i = 0 ; i < 100 ; i++){ TextView tv = new TextView(this); tv.setText("Bonsoir ! " + i); table.addView(tv); } scroll.addView(table); setContentView(scroll); } PS : je crois que l'utilisation des XML est conseillée dans la mesure du possible :) Link to comment Share on other sites More sharing options...
DevAndroid Posted August 26, 2010 Author Share Posted August 26, 2010 merci Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.