menu FixWins.com Spring MVC Spring Boot NodeJS+ExpressJS+Mysql ReactJS+NodeJS+Mysql ReactJS+Redux :CRUD Android PFE
Spring MVC Spring Boot NodeJS+ExpressJS+Mysql ReactJS+NodeJS+Mysql ReactJS+Redux :CRUD PFE

Android : formulaire

Créer un formulaire d'inscription d'un client

1.Layout

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFC107"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Inscription"
android:textSize="25dp"
android:gravity="center"
android:background="#F9FBFB"
android:layout_weight="18"
android:textStyle="bold"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Votre Nom"
android:background="#FFF"
android:textSize="20dp"
android:inputType="text"
android:layout_marginBottom="2dp"
android:padding="3dp"
android:id="@+id/clientNom"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Votre Prenom"
android:background="#FFF"
android:textSize="20dp"
android:layout_marginBottom="2dp"
android:padding="3dp"
android:inputType="text"
android:id="@+id/clientPrenom"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Votre Email"
android:background="#FFF"
android:textSize="20dp"
android:inputType="textEmailAddress"
android:layout_marginBottom="2dp"
android:padding="3dp"
android:id="@+id/clientEmail"/>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Masculin"
android:textSize="20dp"
android:id="@+id/clientmasculin"
android:layout_marginBottom="2dp"
android:padding="3dp"/>
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/clientfeminin"
android:text="Féminin"
android:textSize="20dp"
android:layout_marginBottom="2dp"
android:padding="3dp"/>


</RadioGroup>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Votre Date Naissance"
android:textSize="20dp"
android:layout_marginBottom="2dp"
android:padding="3dp"
android:background="#fff"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/clientdateNaissance"
android:tooltipText="Date Naissances"
android:inputType="date"
android:background="#fff"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Votre Ville"
android:textSize="20dp"
android:layout_marginBottom="2dp"
android:padding="3dp"
android:background="#fff"/>
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/clientVille"
android:textSize="20dp"
android:layout_marginBottom="2dp"
android:padding="3dp"
android:background="#fff"/>
<Switch
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Accepté?"
android:textSize="20dp"
android:layout_marginBottom="2dp"
android:padding="3dp"
android:background="#fff"
android:id="@+id/clientReponse"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Niveau de Satisfaction"
android:textSize="20dp"
android:layout_marginBottom="2dp"
android:padding="3dp"
android:background="#fff"/>
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20dp"
android:layout_marginBottom="2dp"
android:padding="3dp"
android:background="#fff"
android:id="@+id/clientSatiscation"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Valider"
android:textSize="20dp"
android:layout_marginBottom="2dp"
android:padding="3dp"
android:id="@+id/clientValider"
android:backgroundTint="#2196F3"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/clientAffichage"/>
</LinearLayout>


</ScrollView>
</LinearLayout>

</LinearLayout>

2.Java


import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.SeekBar;
import android.widget.Spinner;
import android.widget.Switch;
import android.widget.TextView;

public class Inscription_Client extends AppCompatActivity implements View.OnClickListener{
//1.Déclaration des objets java
EditText clientNom,clientPrenom,clientEmail; //<input
Spinner clientVille; //<select
SeekBar clientSatifaction;//<input type=range
RadioButton clientMasculin,clientFeminin;//<input type=radio
EditText clientNaissance;
TextView clientAffichage;//<span>
Button clientValider;
Switch clientAccepte;//<input type="chekcbox"
//2.Déclaration des variables globales

//le tableau villes sera utilsé pour remplir le spinner ClientVille
String[] villes={"Casablanca","Fes","Tanger","dakhla","oujda","smara"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_inscription__client);
//3.la laision entre les objets graphiques et les objets java
clientNom=findViewById(R.id.clientNom);
clientPrenom=findViewById(R.id.clientPrenom);
clientEmail=findViewById(R.id.clientEmail);
clientVille=findViewById(R.id.clientVille);
clientSatifaction=findViewById(R.id.clientSatiscation);
clientMasculin=findViewById(R.id.clientmasculin);
clientFeminin=findViewById(R.id.clientfeminin);
clientNaissance=findViewById(R.id.clientdateNaissance);
clientAffichage=findViewById(R.id.clientAffichage);
clientValider=findViewById(R.id.clientValider);
clientAccepte=findViewById(R.id.clientReponse);

//4.ecoutez les objets cliquable
clientValider.setOnClickListener(this);

//remplir le spinner avec les valeurs du tableau villes
ArrayAdapter ad=new ArrayAdapter<String>(this,
R.layout.support_simple_spinner_dropdown_item,villes);
//le style des options du spinner ,les valeurs

//affecter l'adpater ou spinner
clientVille.setAdapter(ad);
}

@Override
public void onClick(View view) {

if(clientValider.getId()==view.getId())
{
String nom=clientNom.getText().toString();
String prenom=clientPrenom.getText().toString();
String email=clientEmail.getText().toString();
String ville=clientVille.getSelectedItem().toString();
int niveaSatisfaction=clientSatifaction.getProgress();

String sexe="";
if(clientMasculin.isChecked()) sexe="Masculin";
if(clientFeminin.isChecked()) sexe="Féminin";

String clientReponse="No";
if(clientAccepte.isChecked()) clientReponse="Yes";

String datenaissance=clientNaissance.getText().toString();


String aff="Nom :"+nom;
aff+="\n Prenom :"+prenom;
aff+="\n email :"+email;
aff+="\n ville :"+ville;
aff+="\n Satisfaction :"+niveaSatisfaction;
aff+="\n sexe :"+sexe;
aff+="\n date Naissance :"+datenaissance;
aff+="\n Accepté :"+clientReponse;
clientAffichage.setText(aff);
}
}
}