0

Possible Duplicate:
How to create a custom dialog

I am making a dialog . I want to creat two button is (" View " ) and " Cancel " button. How do I creat " View " button on Dialog ?

Community
  • 1
  • 1
Cong Binh
  • 77
  • 1
  • 7

2 Answers2

3

Instead of creating a custom dialog, you can use the dialog.ask like the code below:

int i = Dialog.ask(""Your text", new String[] {"View", "Cancel"}, new int[] {1, 2}, 1);
if (i == 1)
     //your code for view button
else if (i == 2)
     //your code for cancel button
Farid Farhat
  • 2,300
  • 1
  • 16
  • 29
  • I want to crate a custom dialog and I use this contrustor :static String []st = new String[] {"View", "Cancel"}; static int [] i = new int [] {1, 2}; public CustomDialog(String s) { super(s, st, i, 1, Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION), Manager.FOCUSABLE); How I set action for " View" and " Cancel " ? – Cong Binh Sep 13 '11 at 10:12
  • No you cant. When creating a custom dialog you will have to create two buttons "view" and "cancel" and add FieldChangeListener to them – Farid Farhat Sep 14 '11 at 19:35
  • nice one. but what if i also want to add EditTextField also to the dialog ??? – Shreyash Mahajan Dec 21 '12 at 10:30
1
  1. Extend your CustomDiaolog from Dialog class
  2. Create the button object that you want to create
  3. Add required listeners or navigationClick or keyChar event
  4. Add them to the CustomDiaolog that's all.
Nilanchala
  • 5,891
  • 8
  • 42
  • 72
  • Hi Neel, I just add new button but it has same size with another button, can I manage it ? and Can I creat a dialog with no button defaut ? – Cong Binh Sep 13 '11 at 05:13
  • sure you can create dialog with no dialog default. also you can manage the size of the button as required. for that you need to customize your button. Visit this link this might help you. http://www.codinguru.com/2011/02/custom-image-buttonfield-in-blackberry.html – Nilanchala Sep 13 '11 at 05:36