Dialog, AlertDialog.Builder or Activity?

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Dialog, AlertDialog.Builder or Activity?

Postby darolla » Tue Dec 30, 2008 12:30 pm

Hi,

I need a modal dialog (something like the calculator). But I've got some heavy problems.

1) I can open a dialog with my own xml:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. Dialog d = new Dialog(this);
  3.  
  4. d.setContentView( R.layout.numpad );
  5.  
  6. d.setTitle( "Betrag wählen" );
  7.  
  8. d.show();
  9.  
  10.  
Parsed in 0.052 seconds, using GeSHi 1.0.8.4

well, it looks nice, just like a modal dialog. but I need to put the button listeners inside the calling activity, and thats ugly !

2) I can use AlertDialog.Builder without xml :cry:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. Builder b = new AlertDialog.Builder(this);
  3.  
  4. b.setTitle("Betrag wählen");
  5.  
  6. b.setPositiveButton("OK", null);
  7.  
  8. b.show();                      
  9.  
  10.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


3) I can use a SubActivity, this way my code stays within the activity, but it doesn't look like a modal dialog rather than a normal activity:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. Intent intent = new Intent();
  3.  
  4. intent.setClass(this, NumpadActivity.class);
  5.  
  6. startActivityForResult(intent, 1234);
  7.  
  8.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


so is there another way for me? maybe I could extend Dialog? or any other suggestions?

greetings,
darolla
User avatar
darolla
Master Developer
Master Developer
 
Posts: 273
Joined: Thu Sep 25, 2008 5:16 pm
Location: Dortmund, Germany

Top

Postby darolla » Mon Jan 12, 2009 9:26 am

I wrote a tutorial for this:

viewtopic.php?p=16192

greetings,
darolla
User avatar
darolla
Master Developer
Master Developer
 
Posts: 273
Joined: Thu Sep 25, 2008 5:16 pm
Location: Dortmund, Germany

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 7 guests