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 : Spinner ,Équipes et matchs

Afficher le calendrier des matches

1.Layout

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="3dp"
android:background="#FFEB3B">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#CDDC39"
android:layout_weight="2.4">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#FCFDFC"
android:layout_marginBottom="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_weight="1"
android:text="Equipe1"
android:textSize="25dp"/>
<Spinner
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_weight="1"
android:id="@+id/spinnerEquipe1"
android:textSize="200dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#FCFDFC"

android:layout_marginBottom="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_weight="1"
android:text="Equipe1"
android:textSize="25dp"/>
<Spinner
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_weight="1"
android:id="@+id/spinnerEquipe2"
android:textSize="200dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#FCFDFC"
android:layout_marginBottom="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_weight="1"
android:text="Date"
android:textSize="25dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_weight="1"
android:id="@+id/dateMatch"
android:textSize="20dp"/>
</LinearLayout>

</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:text="OK"
android:id="@+id/bajouterMatch"
android:textSize="20dp"
android:backgroundTint="#2196F3"/>


<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3.1"
android:text="Liste match"
android:textSize="25dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#8BC34A"
android:layout_weight="1.2"
android:paddingTop="8dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:textSize="20dp"
android:text="Date Equipe1 vs Equipe2"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20dp"
android:background="#fff"
android:layout_marginTop="2dp"
android:id="@+id/listeMatch"/>
</LinearLayout>
</LinearLayout>

2.Java


public class Match_Equipes extends AppCompatActivity implements View.OnClickListener{
Spinner spinnerEquipe1,spinnerEquipe2;
EditText dateMatch;
Button bajouterMatch;
TextView listeMatch;
String []equipes1={"Equipe1","Equipe2","Equipe3"};
String []equipes2={"Equipe1","Equipe2","Equipe3"};
String listeMatchs="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_match__equipes);
//1.laision entre les objets graphiques et les objets java
spinnerEquipe1=findViewById(R.id.spinnerEquipe1);
spinnerEquipe2=findViewById(R.id.spinnerEquipe2);
bajouterMatch=findViewById(R.id.bajouterMatch);
listeMatch=findViewById(R.id.listeMatch);
dateMatch=findViewById(R.id.dateMatch);
//2.Remplir les spinner
ArrayAdapter<String>addapter1=new ArrayAdapter<>(this,R.layout.support_simple_spinner_dropdown_item,equipes1);
spinnerEquipe1.setAdapter(addapter1);
ArrayAdapter<String>addapter2=new ArrayAdapter<>(this,R.layout.support_simple_spinner_dropdown_item,equipes2);
spinnerEquipe2.setAdapter(addapter2);
//ecoutez les objets cliquable
bajouterMatch.setOnClickListener(this);
}
@Override
public void onClick(View view) {
if(view.getId()==bajouterMatch.getId())
{
String equipe1=spinnerEquipe1.getSelectedItem().toString();
String equipe2=spinnerEquipe2.getSelectedItem().toString();
String datematchs=dateMatch.getText().toString();
if(equipe1=="" || equipe2=="" || datematchs=="")
{
listeMatch.setText("Erreur tout les champs sont obligatoires");
}
else
{
listeMatchs+=datematchs+" "+equipe1+" "+equipe2+"\n";
listeMatch.setText(listeMatchs);
}
}
}
}