Show dialog as main window, with transparent background

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

Show dialog as main window, with transparent background

Postby Azlum » Fri Apr 10, 2009 5:05 pm

Hey guys...

First of all, sorry if I'm just a retard here.... I'm JUST getting started coding java, and until 2 days ago I hadn't touched a line of code in over 10 years.

Anyways... I'm trying to write an app and when launched I want it to open a dialog, but without having a black activity behind it. I just want the dialog to pop up so it looks like you haven't left the home screen.

So far I THINK I'm going about this wrong to begin with... but you guys will know better than me... I'm just gonna paste the code I have and maybe you guys can help me out?

Thanks SO much in advance!

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class QuikNote extends Activity {
  3.  
  4.         private static final int DIALOG_CREATE = 1;
  5.  
  6.         private static final int DIALOG_EDIT = 2;
  7.  
  8.        
  9.  
  10.     /** Called when the activity is first created. */
  11.  
  12.     @Override
  13.  
  14.     public void onCreate(Bundle savedInstanceState) {
  15.  
  16.         super.onCreate(savedInstanceState);
  17.  
  18.         //setTheme(android.R.style.Theme_Translucent_NoTitleBar);
  19.  
  20.         //getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
  21.  
  22.         //setContentView(R.layout.main);
  23.  
  24.         showDialog(DIALOG_CREATE);
  25.  
  26.     }
  27.  
  28.    
  29.  
  30.     protected Dialog onCreateDialog(int id) {
  31.  
  32.         switch (id) {
  33.  
  34.         case DIALOG_CREATE:
  35.  
  36.                     LayoutInflater factory = LayoutInflater.from(this);
  37.  
  38.                     final View textEntryView = factory.inflate(R.layout.create_dialog, null);
  39.  
  40.                     return new AlertDialog.Builder(QuikNote.this)
  41.  
  42.                         .setIcon(R.drawable.create_dialog_icon)
  43.  
  44.                         .setTitle(R.string.create_dialog_title)
  45.  
  46.                         .setView(textEntryView)
  47.  
  48.                         .setPositiveButton(R.string.create_dialog_ok, new DialogInterface.OnClickListener() {
  49.  
  50.                             public void onClick(DialogInterface dialog, int whichButton) {
  51.  
  52.                                
  53.  
  54.                                 finish();
  55.  
  56.                             }
  57.  
  58.                         })
  59.  
  60.                         .setNegativeButton(R.string.create_dialog_cancel, new DialogInterface.OnClickListener() {
  61.  
  62.                             public void onClick(DialogInterface dialog, int whichButton) {
  63.  
  64.                                
  65.  
  66.                                 finish();
  67.  
  68.                             }
  69.  
  70.                         })
  71.  
  72.                         .create();
  73.  
  74.         }
  75.  
  76.         return null;
  77.  
  78.     }
  79.  
  80. }
  81.  
  82.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4
Azlum
Freshman
Freshman
 
Posts: 2
Joined: Fri Apr 10, 2009 5:01 pm

Top

Postby Azlum » Fri Apr 10, 2009 5:25 pm

Nevermind... I WAS going about it the wrong way altogether.... I should have made the activity itself the dialog by using android:theme="@android:style/Theme.Dialog" in the manifest.

Thanks anyways!
Azlum
Freshman
Freshman
 
Posts: 2
Joined: Fri Apr 10, 2009 5:01 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 2 guests