Aller au contenu
View in the app

A better way to browse. Learn more.

Forum de Frandroid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

création d'une application

Featured Replies

Posté(e)

Bonjour,
je doit faire une application pour mon club afin de gérer les consommations de boissons sur une tablette. Je débute sur android.
Il faudrait indiquer la date (si possible afficher un calendrier en cliquant dessus)
cliquer sur le nom de la personne
cliquer sur un champ quantité consommée
et un champ quantité payée
avoir un bouton qui lorsque l'on clique dessus, les résultats s'enregistre dans un fichier
Voici le code que j'ai déjà réaliser :
activity_main.xml

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

xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.conso.MainActivity"
android:weightSum="1">

<TextView

android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="32dp"
android:gravity="center"
android:text="Date : "
android:textColor="#FF0000"
android:textStyle="bold"
tools:ignore="HardcodedText,MissingConstraints,NestedWeights"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />

<EditText

android:id="@+id/date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="date"
android:inputType="datetime"
tools:ignore="HardcodedText,MissingConstraints"
tools:layout_editor_absoluteX="67dp"
tools:layout_editor_absoluteY="-5dp" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal"
android:weightSum="1"
tools:ignore="InefficientWeight,MissingConstraints"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="24dp">
<TextView

android:layout_width="252dp"
android:layout_height="32dp"
android:gravity="center"
android:text="Joueur : "
android:textColor="#FF0000"
android:textStyle="bold"
tools:ignore="HardcodedText,MissingConstraints,NestedWeights"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />

<Spinner
android:id="@+id/joueur"
android:layout_width="fill_parent"
android:layout_height="39dp"
android:hint="@string/joueur" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal"
android:weightSum="1"
tools:ignore="InefficientWeight,MissingConstraints"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="24dp">
<TextView

android:layout_width="252dp"
android:layout_height="32dp"
android:gravity="center"
android:text="Quantité dûe: "
android:textColor="#FF0000"
android:textStyle="bold"
tools:ignore="HardcodedText,MissingConstraints,NestedWeights"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />

<Spinner
android:id="@+id/qtedue"
android:layout_width="match_parent"
android:layout_height="39dp"
android:hint="@string/qtedue"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal"
android:weightSum="1"
tools:ignore="InefficientWeight,MissingConstraints"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="24dp">
<TextView

android:layout_width="252dp"
android:layout_height="32dp"
android:gravity="center"
android:text="Quantité payée : "
android:textColor="#FF0000"
android:textStyle="bold"
tools:ignore="HardcodedText,MissingConstraints,NestedWeights"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />

<Spinner
android:id="@+id/qtepayee"
android:layout_width="match_parent"
android:layout_height="39dp"
android:hint="@string/qtepayee" />
</LinearLayout>
<!--<Button
android:id="@+id/Valider"
android:layout_width="fill_parent"
android:layout_height="36dp"
android:text="@string/valider" />

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.81">-->

<TextView
android:id="@+id/information"
android:layout_width="105dp"
android:layout_height="31dp"
android:layout_gravity="center"
android:layout_marginTop="12dp"
android:text="@string/en_attente" />
<!--</RelativeLayout>-->


</LinearLayout>

et MainActivity.java

package com.conso;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;

import static android.R.layout.simple_spinner_item;

public class MainActivity extends AppCompatActivity {

private Button active;
private Spinner list = null;
private Spinner list1 = null;
private Spinner list2;
private TextView text;

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

final Spinner list = (Spinner) findViewById(R.id.joueur);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, simple_spinner_item, JR);

adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

list.setAdapter(adapter);
list.setSelection(0);

final Spinner list1 = (Spinner) findViewById(R.id.qtedue);
ArrayAdapter<String> adapter1;
adapter1 = new ArrayAdapter<String>(this, simple_spinner_item, DD);

adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

list1.setAdapter(adapter1);

/*final Spinner list2 = (Spinner) findViewById(R.id.qtepayee);
ArrayAdapter<String> adapter2;
adapter2 = new ArrayAdapter<String>(this, simple_spinner_item, DP);

adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

list.setAdapter(adapter2);*/


/*final Button active = (Button) findViewById(R.id.valider);
active.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
Option();
}
});*/

}

static final String[] JR = new String[]{"alphonse","didier","rené"
};

static final String[] DD = new String[]{"1","2","3","4","5"
};

/*static final String[] DP = new String[]{"1","2","3","4","5"
};*/

/*private void Option() {
Button active = (Button) findViewById(R.id.valider);
if (active != null) {
Spinner list = (Spinner) findViewById(R.id.joueur);
TextView text = (TextView) findViewById(R.id.information);
if ((list != null) || list.isEnabled()) {
list.setEnabled(true);
active.setText("Valider");
text.setText("En attente");
} else {
switch (list.getSelectedItemPosition()) {
case 0:
text.setText("Android");
break;
case 1:
text.setText("BlackBerry");
break;
case 2:
text.setText("Firefox");
break;
case 3:
text.setText("iOS");
break;
case 4:
text.setText("Ubuntu");
break;
case 5:
text.setText("Windows");
break;
}
list.setEnabled(false);
active.setText(R.string.OK);


}
}

}*/
}

Mes problèmes sont les suivants:
si j'active les 3 listes, lorsque je lance l'émulateur, la deuxième liste s'affiche dans la première et la 3ème dans la deuxième et il n'y a rien dans la 3ème.
si j'active le bouton, l'application plante

Quelqu'un pourrait-il m'aider svp?

Rejoignez la conversation

Vous pouvez poster maintenant et vous enregistrez plus tard. Si vous avez un compte, connectez-vous maintenant pour poster.

Invité
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Répondre à ce sujet…

Account

Navigation

Rechercher

Rechercher

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.