0% found this document useful (0 votes)
21 views2 pages

Intent Explicite

The document defines an XML layout file with EditText fields for name and last name and a button. It also defines a Java class with a button click listener that starts a new activity, passing the EditText values as extras under keys 'clé1' and 'clé2'.

Uploaded by

Mohamed Belghith
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

Intent Explicite

The document defines an XML layout file with EditText fields for name and last name and a button. It also defines a Java class with a button click listener that starts a new activity, passing the EditText values as extras under keys 'clé1' and 'clé2'.

Uploaded by

Mohamed Belghith
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

<?xml version="1.0" encoding="utf-8"?

>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">

<EditText
android:id="@+id/edt1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName"
android:selectAllOnFocus="true" />

<EditText
android:id="@+id/edt2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Last Name"
android:inputType="textPersonName" />

<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Suivant" />

</LinearLayout>

package com.example.a3_intent_explicie_passagedevaleur;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

Button b;
EditText e1,e2;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

b=findViewById(R.id.btn1);
e1=findViewById(R.id.edt1);
e2=findViewById(R.id.edt2);

b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this, MainActivity2.class);
i.putExtra("clé1",e1.getText().toString());
i.putExtra("clé2",e2.getText().toString());
startActivity(i);

}
});

}
}

You might also like