sifokl Posted March 30, 2012 Share Posted March 30, 2012 Bonjour, je suis en train de me former en developpement android ! ce bout de code permet de generer un bouton et une zone "edit text" , puis , en cliquant sur le bouton , la chaine de caractere "Lamkenti" (que jai choisi arbitrairement) doit apparaitre dans la zone dit text ! or , ce n'est pas le cas : la zone edit text demeure vide ! pouviez vous m'aider et me dire ou est le probleme ? Merci beaucoup ! voila le code du Main package com.formation.activite;[/size][/font][/color] [color=#303030][font=verdana][size=3]import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText;[/size][/font][/color] [color=#303030][font=verdana][size=3]public class Main extends Activity implements OnClickListener { Button button; EditText edit;[/size][/font][/color] [color=#303030][font=verdana][size=3]@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); button = ((Button)this.findViewById(R.id.boutton1)); edit = ((EditText)this.findViewById(R.id.edit1)); button.setOnClickListener(this); if (this.getIntent().getExtras() != null) { String s= this.getIntent().getExtras().getString("maDonee"); edit.setText(s); } Log.i("", "onCreate"); } @Override protected void onStart() { Log.i("", "onStart"); super.onStart(); } @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); Log.i("", "onPause"); } @Override protected void onResume() { Log.i("", "onResume"); super.onResume(); } @Override protected void onStop() { Log.i("", "onStop"); super.onStop(); } @Override protected void onDestroy() { Log.i("", "onDestroy"); super.onDestroy(); } public void onClick(View arg0) {[/size][/font][/color] [color=#303030][font=verdana][size=3] Intent intent = new Intent(this,Main.class); intent.putExtra("maDonnee", "Lamkenti"); this.startActivityForResult(intent, 1000); } }[/size][/font][/color] [color=#303030][font=verdana][size=3] et celui du layout Main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="[url="http://schemas.android.com/apk/res/android"]http://schemas.android.com/apk/res/android[/url]" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <Button android:id="@+id/boutton1" android:layout_width="fill_parent" android:layout_height="wrap_content" > </Button> <EditText android:id="@+id/edit1" android:layout_width="fill_parent" android:layout_height="wrap_content" > </EditText> </LinearLayout> Link to comment Share on other sites More sharing options...
Sylvain-a Posted March 30, 2012 Share Posted March 30, 2012 Heu pourquoi tu lances une activity (la même en plus)? Link to comment Share on other sites More sharing options...
sifokl Posted March 30, 2012 Author Share Posted March 30, 2012 @Sylvain-a Desolé , je suis débutant , tres Débutant :) pouviez vous expliquer d'avantage ? :P Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.