Android Lab Test : Creating a dialog Yes/No (english)
Video of tutorial on : https://www.youtube.com/playlist?list=PLL2Z3bzdO25yHwIV3XdMzKs61At0Ldh6L
Visit http://www.AndroidLabTest.com
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Android Lab Test : Creating a dialog Yes/No (english)
1. Develop on Android
Android Lab Test
www.AndroidLabTest.com
Youku
By Bruno Delb
www.weibo.com/brunodelb
i.youku.com/brunodelb | www.weibo.com/brunodelb | blog.delb.cn
http://i.youku.com/brunoparis
Weibo
Officialsite
Lesson : The dialog, YesNo
2. The dialog, YesNo
• In this lesson, you will learn to create and display a
dialog box.
• For this, you will use the Dialog.
3. The dialog, YesNo
• To create a new Dialog, call the method Builder.
AlertDialog.Builder alertDialog = new AlertDialog.Builder(Main.this);
• You can specify an icon with he method setIcon(), a title with the
method setTitle() and a message with the method setMessage().
alertDialog.setIcon(R.drawable.app);
alertDialog.setTitle("Your title");
alertDialog.setMessage("Your message");
4. The dialog, YesNo
• To add a button « positive » (in the meaning of « Yes »), call themethod
setPositiveButton(). Then add a listener OnClickListener and the method
onClick().
alertDialog.setPositiveButton("Yes!", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int arg1) { }
});
• Repeat the operation with a button « negative » (in the meaning of « No »),
with the method setNegativeButton().
alertDialog.setNegativeButton("No!", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int arg1) { }
});
5. The dialog, YesNo
• To manage the action of cancel, call the methode setOnCancelListener.
alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener(){
public void onCancel(DialogInterface dialog) { }
});
• To display the Dialog, call the method show() :
alertDialog.show();
10. Follow me on my channel PengYooTV …
On my Youku channel
http://i.youku.com/brunoparis
Who am I ?
Bruno Delb (www.delb.cn),
Author of the first french book of development of Java mobile application (2002),
Consultant, project manager and developer of social & mobile applications,
let’s talk about your needs ...
And on Weibo :
http://www.weibo.com/brunodelb