Ses propres ecouteur android
Fermé
hjbb
Messages postés
7
Date d'inscription
lundi 18 février 2013
Statut
Membre
Dernière intervention
22 février 2013
-
18 févr. 2013 à 12:20
hjbb Messages postés 7 Date d'inscription lundi 18 février 2013 Statut Membre Dernière intervention 22 février 2013 - 22 févr. 2013 à 22:54
hjbb Messages postés 7 Date d'inscription lundi 18 février 2013 Statut Membre Dernière intervention 22 février 2013 - 22 févr. 2013 à 22:54
A voir également:
- Ses propres ecouteur android
- Mode sécurisé android - Guide
- Un ecouteur sur deux marche ✓ - Forum Audio
- Télécharger vidéo youtube android - Guide
- Android recovery - Guide
- Sonnerie android - Guide
1 réponse
scinarf
Messages postés
1098
Date d'inscription
samedi 18 novembre 2006
Statut
Membre
Dernière intervention
25 septembre 2014
291
18 févr. 2013 à 13:32
18 févr. 2013 à 13:32
Bonjour,
Pourrais je vois voir votre code dans la Class, histoire de voir ou est le problème.
Quel IDE utilisez vous ?
Sur quel version(API) de Android vous de développer ?
Pourrais je vois voir votre code dans la Class, histoire de voir ou est le problème.
Quel IDE utilisez vous ?
Sur quel version(API) de Android vous de développer ?
Modifié par hjbb le 18/02/2013 à 14:23
package com.example.repondeur; import android.content.Context; import android.graphics.Color; import android.util.AttributeSet; import android.view.Gravity; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; public class Wheel extends LinearLayout { Button up, down; int max, min; int wrap = LayoutParams.WRAP_CONTENT; int fill = LayoutParams.FILL_PARENT; TextView num; public Wheel(Context context) { super(context); max = 10; min = 1; setOrientation(LinearLayout.VERTICAL); setLayoutParams(new LayoutParams(wrap, wrap)); init(); } public Wheel(Context context, AttributeSet attrs) { super(context, attrs); max = 10; min = 1; init(); } //private void init(AttributeSet attrs) {} public Wheel(Context context, int tmp, int tmp2) { super(context); max = tmp; min = tmp2; setOrientation(LinearLayout.VERTICAL); setLayoutParams(new LayoutParams(wrap, wrap)); init(); } private void init() { Context ctx = this.getContext(); up = new Button(ctx); down = new Button(ctx); num = new TextView(ctx); up.setText("+"); down.setText("-"); num.setText(Integer.toString(min)); num.setGravity(Gravity.CENTER); num.setTextColor(Color.WHITE); up.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int tmp = Integer.valueOf((String) num.getText()) + 1 ; if (tmp > max){ tmp = min; } String chtmp = Integer.toString(tmp); num.setText(chtmp); //fireModifier(new ModifierEvent(Wheel.this, true)); } }); down.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int tmp = Integer.valueOf((String) num.getText()) - 1 ; if (tmp < min){ tmp = max; } String chtmp = Integer.toString(tmp); num.setText(chtmp); //fireModifier(new ModifierEvent(Wheel.this, false)); } }); addView(up, new LinearLayout.LayoutParams(fill, wrap)); addView(num, new LinearLayout.LayoutParams(fill, wrap)); addView(down, new LinearLayout.LayoutParams(fill, wrap)); } public int getNum(){ return Integer.valueOf(num.getText().toString()); } public String getNumOnString(){ return num.getText().toString(); } public void setMaxMin(int ma, int mi){ max = ma; min = mi; } }19 févr. 2013 à 09:59
19 févr. 2013 à 10:03
https://stackoverflow.com/questions/5703548/android-onclick-method-doesnt-work-on-a-custom-view
C'est anglais, mais je ne pense pas que cela pose problème.
19 févr. 2013 à 20:06
20 févr. 2013 à 08:23
Voila qui pourra me servir plus tard.