alan700 Posted December 31, 2014 Share Posted December 31, 2014 Bonjour j'ai une petite question je suis en train de créer mon application android avec android studio. Mon petit problème c'est que je voudrais que dès que je clique sur le bouton sa ouvre un lien vers le navigateur. Quote Link to comment Share on other sites More sharing options...
Nhi Posted December 31, 2014 Share Posted December 31, 2014 (edited) String url = "http://www.example.com"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); Edited December 31, 2014 by Nhi Quote Link to comment Share on other sites More sharing options...
alan700 Posted January 1, 2015 Author Share Posted January 1, 2015 Merci mais je ne c'est où le placer. Quote Link to comment Share on other sites More sharing options...
Nhi Posted January 1, 2015 Share Posted January 1, 2015 Ba ajoute un onclicklistener sut ton bouton Quote Link to comment Share on other sites More sharing options...
alan700 Posted January 1, 2015 Author Share Posted January 1, 2015 (edited) excuse moi mes je suis debutent dans le codage android. comment Edited January 1, 2015 by alan700 Quote Link to comment Share on other sites More sharing options...
Nhi Posted January 1, 2015 Share Posted January 1, 2015 Button bouton = (Button) findViewById(R.id.mybouton); bouton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String url = "http://www.example.com"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }); et dans le R.id.bouton le bouton à la fin représente l'identifiant de ta vue Button que tu as dans ton xml donc adapte le en fonction de l'id que tu as. Si t'arrives pas à faire un truc aussi basique faudrait que tu relise ton tuto parce que t'avanceras pas si tu sais pas faire ça. 1 Quote Link to comment Share on other sites More sharing options...
alan700 Posted January 1, 2015 Author Share Posted January 1, 2015 (edited) ok excuse-moi mes j'ai une erreur dès que je mes setOnClicklistener. Edited January 1, 2015 by alan700 Quote Link to comment Share on other sites More sharing options...
Nhi Posted January 1, 2015 Share Posted January 1, 2015 Ces lignes la ça se met dans le oncreate après le setcontentview ... 1 Quote Link to comment Share on other sites More sharing options...
alan700 Posted January 1, 2015 Author Share Posted January 1, 2015 merci je peut enfin finir mon appli merci de ton aide. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.