Developpement Android

Fermé
sifokl Messages postés 24 Date d'inscription samedi 24 mars 2012 Statut Membre Dernière intervention 20 novembre 2015 - 30 mars 2012 à 02:23
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;

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;

public class Main extends Activity implements OnClickListener {
	
	Button button;
	EditText edit;

	
	@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) {

		Intent intent = new Intent(this,Main.class);
		intent.putExtra("maDonnee", "Lamkenti"); 
		this.startActivityForResult(intent, 1000);
		
	}



}



et celui du layout Main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    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>