Custom component using custom dialog

by Nigel » Wed, 09 Sep 2009 02:15:28 GMT


Sponsored Links
 My application needs to be aware of a custom dialog, which is used
only by a custom component.  By "aware" I mean through the
onCreateDialog and onPrepareDialog.

I would like the dialog to be fully encapsulated by the component, but
if the component performs a:

Dialog d = new CustomDialog(getContext());
d.show();

rather than:

Activity a = (Activity)getContext();
a.showDialog(CustomDialog.ID);

I get an exception - primarily because the dialog's "onCreate(Bundle
b)" method doesn't get automatically called.

I'm looking for opinions on the best way to structure the code...

Comments welcomed.

Thanks,

Nigel

--~--~---------~--~----~------------~-------~--~----~



Custom component using custom dialog

by Nigel » Thu, 10 Sep 2009 13:35:33 GMT


 In the end I have performed this with the client code making an
explicit call to perform the required initialisation.  This doesn't
feel right, but it works.



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Optus telco in Australia now allowing paid apps from Market

Hi,

Good news, after a year of blocking, Optus telco in Australia now
allowing paid apps from Market.

Hopefully Australian developers can soon offer paid apps as well ? :-)

Regards

-- 

2. Help converting C# code (Isn't there anyone that will help out here)

I am trying to convert a C# game to Android and need some help with
the graphics stuff.

Can anyone show me how to convert this to Java?

using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace MyGame
{
 public partial class MyButton : Button
 {
   GraphicsPath path;
   GraphicsPath innerPath;

   private bool _clicked = false;
   public bool Clicked
   {
     get { return _clicked; }
     set
     {
       _clicked = value;
       Invalidate();
     }
   }

   public MyButton()
   {
     InitializeComponent();
   }

   protected override void OnPaint(PaintEventArgs pevent)
   {
     Graphics g = pevent.Graphics;
     g.SmoothingMode = SmoothingMode.AntiAlias;

     // Create painting objects
     Brush b = new SolidBrush(this.ForeColor);

     // Create Rectangle To Limit brush area.
     Rectangle rect = new Rectangle(0, 0, 150, 150);

     LinearGradientBrush linearBrush =
       new LinearGradientBrush(rect,
       Color.FromArgb(20,20,20),
       this.ForeColor,
       225);

     path = new GraphicsPath();
     innerPath = new GraphicsPath();

     path.AddArc(0, 0, 270, 270, 180, 90);
     path.AddArc(120, 0, 30, 30, 270, 90);
     path.AddLine(150, 0, 150, 85);
     path.AddArc(100, 100, 100, 100, -90, -90);
     path.AddLine(100, 150, 0, 150);
     path.AddArc(0, 120, 30, 30, 90, 90);

     innerPath.AddArc(10, 10, 250, 250, 180, 90);
     innerPath.AddArc(130, 10, 10, 10, 270, 90);
     innerPath.AddLine(140, 0, 140, 90);
     innerPath.AddArc(90, 90, 100, 100, -90, -90);
     innerPath.AddLine(90, 140, 10, 140);
     innerPath.AddArc(10, 130, 10, 10, 90, 90);

     this.Region = new Region(path);

     PathGradientBrush pgbrush = new PathGradientBrush(innerPath);
     pgbrush.CenterPoint = new Point(75, 75);
     pgbrush.CenterColor = Color.White;
     pgbrush.SurroundColors = new Color[] {
                            Color.FromArgb(250,this.ForeColor) };

     if (_clicked == false)
     {
       g.FillPath(linearBrush, path);
       g.FillPath(b, innerPath);
     }
     else
     {
       g.FillPath(linearBrush, path);
       g.FillPath(pgbrush, innerPath);
     }

     // Dispose of painting objects
     b.Dispose();
     pgbrush.Dispose();
     linearBrush.Dispose();
   }

   protected override void OnMouseEnter(EventArgs e)
   {
     this.Cursor = Cursors.Hand;
     base.OnMouseEnter(e);
   }

   protected override void OnMouseLeave(EventArgs e)
   {
     this.Cursor = Cursors.Arrow;
     base.OnMouseLeave(e);
   }

   protected override void OnMouseDown(MouseEventArgs mevent)
   {
     _clicked = true;
     base.OnMouseDown(mevent);
   }

   protected override void OnMouseUp(MouseEventArgs mevent)
   {
     _clicked = false;
     base.OnMouseUp(mevent);
   }
 }
}

-- 

3. Can anyone hook me up with an Exchange email account that I could use for testing?

4. Control a graphic with android buttons

5. external input device

6. Programmatically setting a new default ringtone without the ringtone picker

7. Setting new default ringtone without using RingtonePicker?