Problème boutons
Fermé
bmaxime18
Messages postés
7
Date d'inscription
samedi 21 mai 2016
Statut
Membre
Dernière intervention
23 mai 2016
-
Modifié par bmaxime18 le 21/05/2016 à 15:30
BunoCS Messages postés 15507 Date d'inscription lundi 11 juillet 2005 Statut Modérateur Dernière intervention 14 mars 2025 - 24 mai 2016 à 08:58
BunoCS Messages postés 15507 Date d'inscription lundi 11 juillet 2005 Statut Modérateur Dernière intervention 14 mars 2025 - 24 mai 2016 à 08:58
A voir également:
- Problème boutons
- Application pour reconnaître les boutons - Accueil - Outils
- Comment réinitialiser un téléphone avec les boutons - Guide
- A quoi servent les boutons de couleur sur une telecommande - Guide
- Comment faire une capture d'écran sans appuyer sur les boutons ? - Guide
- Problème bouton volume autoradio ✓ - Forum Audio
8 réponses
ElementW
Messages postés
4814
Date d'inscription
dimanche 12 juin 2011
Statut
Contributeur
Dernière intervention
5 octobre 2021
1 227
21 mai 2016 à 16:36
21 mai 2016 à 16:36
'lut
Je clique dessus mais rien ne se passe.Mais, vois-tu, il serait plus qu'utile que tu nous fournisse ton code, sans ça on ne pourra jamais savoir ce qui cloche...
BunoCS
Messages postés
15507
Date d'inscription
lundi 11 juillet 2005
Statut
Modérateur
Dernière intervention
14 mars 2025
3 914
23 mai 2016 à 09:02
23 mai 2016 à 09:02
Hello,
Je n'ai pas forcément envie de télécharger un fichier rar...
Peux-tu poster le code Java de l'Activity et le XML qui lui correspond?
Je n'ai pas forcément envie de télécharger un fichier rar...
Peux-tu poster le code Java de l'Activity et le XML qui lui correspond?
bmaxime18
Messages postés
7
Date d'inscription
samedi 21 mai 2016
Statut
Membre
Dernière intervention
23 mai 2016
23 mai 2016 à 17:23
23 mai 2016 à 17:23
Voici le MainActivity.java
Et le xml qui lui correspond
package com.dfrobot.angelo.blunobasicdemo; import android.content.Context; import android.os.Bundle; import android.content.Intent; import android.util.Log; import android.util.LogPrinter; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.ScrollView; import android.widget.TextView; public class MainActivity extends BlunoLibrary { private Button buttonScan; private Button buttonAvance; private Button buttonSerialSend; private EditText serialSendText; private TextView serialReceivedText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); onCreateProcess(); //onCreate Process by BlunoLibrary serialBegin(115200); //set the Uart Baudrate on BLE chip to 115200 //serialReceivedText=(TextView) findViewById(R.id.serialReveicedText); //initial the EditText of the received data //serialSendText=(EditText) findViewById(R.id.serialSendText); //initial the EditText of the sending data buttonAvance = (Button) findViewById(R.id.button_avance); buttonAvance.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { serialSend("a"); } }); Button ButtonRecule = (Button) findViewById(R.id.button_recule); ButtonRecule.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { serialSend("r"); } }); Button ButtonDroite = (Button) findViewById(R.id.button_droite); ButtonDroite.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { serialSend("d"); } }); Button ButtonGauche = (Button) findViewById(R.id.button_gauche); ButtonGauche.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { serialSend("g"); } }); buttonScan = (Button) findViewById(R.id.buttonScan); //initial the button for scanning the BLE device buttonScan.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub buttonScanOnClickProcess(); //Alert Dialog for selecting the BLE device } }); } protected void onResume(){ super.onResume(); System.out.println("BlUNOActivity onResume"); onResumeProcess(); //onResume Process by BlunoLibrary } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { onActivityResultProcess(requestCode, resultCode, data); //onActivityResult Process by BlunoLibrary super.onActivityResult(requestCode, resultCode, data); } @Override protected void onPause() { super.onPause(); onPauseProcess(); //onPause Process by BlunoLibrary } protected void onStop() { super.onStop(); onStopProcess(); //onStop Process by BlunoLibrary } @Override protected void onDestroy() { super.onDestroy(); onDestroyProcess(); //onDestroy Process by BlunoLibrary } @Override public void onConectionStateChange(connectionStateEnum theConnectionState) {//Once connection state changes, this function will be called switch (theConnectionState) { //Four connection state case isConnected: buttonScan.setText("Connected"); break; case isConnecting: buttonScan.setText("Connecting"); break; case isToScan: buttonScan.setText("Scan"); break; case isScanning: buttonScan.setText("Scanning"); break; case isDisconnecting: buttonScan.setText("isDisconnecting"); break; default: break; } } @Override public void onSerialReceived(String theString) { //Once connection data received, this function will be called // TODO Auto-generated method stub serialReceivedText.append(theString); //append the text into the EditText //The Serial data from the BLUNO may be sub-packaged, so using a buffer to hold the String is a good choice. ((ScrollView)serialReceivedText.getParent()).fullScroll(View.FOCUS_DOWN); } }
Et le xml qui lui correspond
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" android:focusable="true" android:focusableInTouchMode="true"> <ScrollView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/scrollView" android:layout_alignParentBottom="true" android:layout_below="@+id/buttonScan" android:visibility="gone"> <TextView android:id="@+id/serialReveicedText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="10" android:textSize="10sp" android:layout_below="@+id/editText2" android:layout_alignStart="@+id/editText2" android:layout_alignEnd="@+id/serialSendText" android:layout_alignParentBottom="true" /> </ScrollView> <Button android:id="@+id/buttonSerialSend" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Send Data" android:layout_centerHorizontal="true" android:visibility="gone" /> <Button android:id="@+id/buttonScan" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Scan" android:layout_alignParentTop="true" android:layout_alignParentEnd="true" /> <ImageView android:layout_width="147dp" android:layout_height="138dp" android:id="@+id/flecheRecule" android:src="@drawable/fleche_gauche" android:layout_centerVertical="true" android:layout_alignParentStart="true" /> <ImageView android:layout_width="138dp" android:layout_height="147dp" android:id="@+id/flecheDroite" android:src="@drawable/fleche_bas" android:layout_alignParentBottom="true" android:layout_alignEnd="@+id/flecheGauche" /> <ImageView android:layout_width="147dp" android:layout_height="138dp" android:id="@+id/flecheAvance" android:src="@drawable/fleche_droite" android:layout_centerVertical="true" android:layout_alignParentEnd="true" /> <ImageView android:layout_width="138dp" android:layout_height="147dp" android:id="@+id/flecheGauche" android:src="@drawable/fleche_haut" android:layout_alignParentTop="true" android:layout_alignParentStart="true" /> <Button android:layout_width="wrap_content" android:layout_height="147dp" android:visibility="invisible" android:id="@+id/button_gauche" android:layout_gravity="center_horizontal|top" android:layout_alignEnd="@+id/flecheGauche" android:layout_alignParentStart="true" /> <Button android:layout_width="wrap_content" android:layout_height="138dp" android:visibility="invisible" android:id="@+id/button_recule" android:layout_gravity="center|bottom" android:layout_centerVertical="true" android:layout_alignParentStart="true" android:layout_alignEnd="@+id/flecheRecule" /> <Button android:layout_width="wrap_content" android:layout_height="147dp" android:visibility="invisible" android:id="@+id/button_avance" android:layout_gravity="center_horizontal|top" android:layout_alignBottom="@+id/flecheAvance" android:layout_alignParentEnd="true" android:layout_alignTop="@+id/flecheAvance" android:layout_alignStart="@+id/flecheAvance" /> <Button android:layout_width="154dp" android:visibility="invisible" android:layout_height="100dp" android:id="@+id/button_droite" android:layout_gravity="end|bottom" android:layout_alignParentStart="true" android:layout_alignBottom="@+id/flecheDroite" android:layout_alignEnd="@+id/flecheDroite" android:layout_alignTop="@+id/flecheDroite" /> </RelativeLayout>
BunoCS
Messages postés
15507
Date d'inscription
lundi 11 juillet 2005
Statut
Modérateur
Dernière intervention
14 mars 2025
3 914
23 mai 2016 à 17:32
23 mai 2016 à 17:32
android:visibility="invisible"
C'est normal, ça? Si les boutons sont invisibles, ils ne reçoivent pas les interactions.
bmaxime18
Messages postés
7
Date d'inscription
samedi 21 mai 2016
Statut
Membre
Dernière intervention
23 mai 2016
23 mai 2016 à 17:44
23 mai 2016 à 17:44
euh je vais essayer sans
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
bmaxime18
Messages postés
7
Date d'inscription
samedi 21 mai 2016
Statut
Membre
Dernière intervention
23 mai 2016
23 mai 2016 à 17:50
23 mai 2016 à 17:50
mais est ce que c'est bien la ligne
pour pouvoir envoyer un message par bluetooth ?
serialSend("g");
pour pouvoir envoyer un message par bluetooth ?
BunoCS
Messages postés
15507
Date d'inscription
lundi 11 juillet 2005
Statut
Modérateur
Dernière intervention
14 mars 2025
3 914
23 mai 2016 à 17:59
23 mai 2016 à 17:59
Ah ça, je ne sais pas...
Faut voir la doc de la méthode
Faut voir la doc de la méthode
serialSend().
bmaxime18
Messages postés
7
Date d'inscription
samedi 21 mai 2016
Statut
Membre
Dernière intervention
23 mai 2016
23 mai 2016 à 18:40
23 mai 2016 à 18:40
et il y a moyen que vous m'envoyez le lien de toutes les docs sur les méthodes Android Studio ?
BunoCS
Messages postés
15507
Date d'inscription
lundi 11 juillet 2005
Statut
Modérateur
Dernière intervention
14 mars 2025
3 914
24 mai 2016 à 08:58
24 mai 2016 à 08:58
Alors, la "doc sur les méthodes d'Android Studio" ne va pas t'apporter grand-chose. Par contre, la doc sur Android, oui. La voici: https://developer.android.com/index.html
A noter que je ne pense pas que
A noter que je ne pense pas que
serialSend()soit une méthode du Framework mais plutôt de BlunoLibrary
21 mai 2016 à 18:18
Voici le lien de mon code : http://www.mediafire.com/file/qgyu3ek7v6kx86e/Android.rar/file
21 mai 2016 à 20:12
Bon. Ça ne me dit pas quel est le bouton qui ne marche pas.... Lequel est censé faire quoi?
21 mai 2016 à 20:14
Le seul qui fonctionne est le scan car il était déjà présent dans le code