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.

Releveur sur un bouton

Featured Replies

Posté(e)

Bonjour, J'aimerai creer un releveur sur un bouton : c'est a dire que lorsque je selectionne un bouton (par defaut il se colore en orange) il change de background et si je le deselectionne, il revient a son background initial. Le probleme c'est que pour mon bouton, que voici :

    <Button
   android:layout_gravity="center_horizontal"
   android:layout_marginTop="7dp"
   android:id="@+id/connection_valid"	
   android:layout_width="wrap_content" 
   android:layout_height="wrap_content"
 	    android:textColor="@color/white"
   android:background="@drawable/valider"/>

.. J'arrive a modifier le background quand on selectionne le bouton via un setOnTouchListener. Cependant je n'arrive pas a percevoir a quel moment je le deselectionne. J'ai bien essaye un setOnFocusChangeListener mais ca ne marche pas .

Quelqu'un aurait il une idee pour me permettre de recupere le moment ou je deselectionne mon bouton ?

Merci de votre aide !

Posté(e)
  • Auteur

Me revoila, J'ai donc essaye de creer un StatListDrawable le probleme que je rencontre c'est pour stocker mon selector : dans le lien ci dessus il creeun fichier dans le dossier drawable cependant j'ai 3 fichiers (sous eclipse) pour les troi principale resolutions et quand j'essaye de mettre mon fichier dans un seul des trois, ca ne marche pas et quand je et dans les trois ..... Ca ne marche toujours pas :) voici ce que cela m'affiche :

11-05 10:43:01.232: WARN/dalvikvm(228): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
11-05 10:43:01.232: ERROR/AndroidRuntime(228): Uncaught handler: thread main exiting due to uncaught exception
11-05 10:43:01.271: ERROR/AndroidRuntime(228): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.App/com.App.App}: android.view.InflateException: Binary XML file line #94: Error inflating class android.widget.Button
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.os.Looper.loop(Looper.java:123)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.app.ActivityThread.main(ActivityThread.java:4363)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at java.lang.reflect.Method.invokeNative(Native Method)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at java.lang.reflect.Method.invoke(Method.java:521)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at dalvik.system.NativeStart.main(Native Method)
11-05 10:43:01.271: ERROR/AndroidRuntime(228): Caused by: android.view.InflateException: Binary XML file line #94: Error inflating class android.widget.Button
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.view.LayoutInflater.createView(LayoutInflater.java:513)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.app.Activity.setContentView(Activity.java:1622)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at com.App.App.onCreate(App.java:70)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     ... 11 more
11-05 10:43:01.271: ERROR/AndroidRuntime(228): Caused by: java.lang.reflect.InvocationTargetException
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.widget.Button.<init>(Button.java:65)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at java.lang.reflect.Constructor.constructNative(Native Method)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.view.LayoutInflater.createView(LayoutInflater.java:500)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     ... 22 more
11-05 10:43:01.271: ERROR/AndroidRuntime(228): Caused by: android.content.res.Resources$NotFoundException: File res/drawable-ldpi/valider_xml.xml from drawable resource ID #0x7f020007
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.content.res.Resources.loadDrawable(Resources.java:1693)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.view.View.<init>(View.java:1850)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.widget.TextView.<init>(TextView.java:326)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.widget.Button.<init>(Button.java:69)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     ... 26 more
11-05 10:43:01.271: ERROR/AndroidRuntime(228): Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #2: invalid drawable tag LinearLayout
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:784)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.graphics.drawable.Drawable.createFromXml(Drawable.java:729)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     at android.content.res.Resources.loadDrawable(Resources.java:1690)
11-05 10:43:01.271: ERROR/AndroidRuntime(228):     ... 30 more

Modifié par Morgan26

Posté(e)
  • Auteur

Ca y est j'ai trouve mon probleme : j'avais mi un LinearLayout et dedans mon selector :) Donc je confirme : il faut bien mettre dans les 3 drawables

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

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.