com.hero Posted July 1, 2010 Share Posted July 1, 2010 Salut à tous! J'ai un petit problème concernant l'affichage d'une alerte dialog J'obtient le warning suivant... et c'est tout, rien d'autre 07-01 09:54:55.271: WARN/InputManagerService(76): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@438b0780 Le contexte est le suivant : J'ai une classe GPS, avec un location listener Lorsque la location change, j'affiche une alerte (à des fins de test) Pour éviter l'affichage à chaque fois, je vérifie que celle ci n'est pas affiché. Voici comment je me débrouille avec l'alerte dialog public class Alerte { private Context context; private AlertDialog.Builder msg; private AlertDialog aPoint; public Alerte(Context c) { this.context = c; msg = new AlertDialog.Builder(context); aPoint = msg.create(); } public void alerteRestaurant(final Restaurant restaurant){ LayoutInflater factory = LayoutInflater.from(context); final View diagView = factory.inflate(R.layout.restaurant, null); ImageAdapter imgadp = new ImageAdapter(context, 2, live.getIdType(), 0); GridView gridview = (GridView) diagView.findViewById(R.id.gridviewPictos); gridview.setAdapter(imgadp); gridview.setSelector(new ColorDrawable(Color.TRANSPARENT)); TextView voie = (TextView) diagView.findViewById(R.id.sur); voie.setText(context.getGps().getVoie()); aPoint.setIcon(R.drawable.logo); aPoint.setTitle(restaurant.getType() + "(" + restaurant.getIdRestaurant() + ")"); aPoint.setView(diagView); aPoint.setMessage("ok"); aPoint.setCancelable(false); aPoint.setButton("Appeler", new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { context.getRestaurant().appeler("" + restaurant.getTel()); } }); aPoint.show(); } public AlertDialog getaPoint() { return aPoint; } } Grâce au debugger, je suis sur que le programme s'exécute correctement, seulement le aPoint.show(); me revois un warning :( Avez une petite idée car je sèche complétement depuis 2 jours :( Merci à vous et bonne journée! Link to comment Share on other sites More sharing options...
Nivek Posted July 3, 2010 Share Posted July 3, 2010 Normalement on fournit les propriétés du Dialog à créer au Dialog.Builder AVANT d'appeler Builder.create(). Tout est là : http://developer.android.com/intl/fr/guide/topics/ui/dialogs.html Link to comment Share on other sites More sharing options...
Nivek Posted July 3, 2010 Share Posted July 3, 2010 Un truc faux dans la doc Android en revanche, il faut impérativement fournir une Activity dans le constructeur du Builder, et non getApplicationContext() Link to comment Share on other sites More sharing options...
com.hero Posted July 6, 2010 Author Share Posted July 6, 2010 Salut Nivek! Je ne reviens que maintenant après un long weekend! J'adapte de suite mon code et reviens poster le résultat Merci pour ta réponse! EDIT : Problème réglé, j'ai rajouté un attribut boolean dans ma classe Alerte initialisé à false avec un getter qui remplace l'attribut isShowing de aPoint et donc j'ai rajouté aPoint.create() avant chaque aPoint.show(). Merci encore à toi pour ta réponse! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.