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>
Afficher la suite