Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 80
Registered: ‎09-03-2012
My Device: 9810
My Carrier: Vodafone

reset() method not working for DateTimePicker.

[ Edited ]

Hi ,

 

I am implementing DateTimePicker in my app on a ButtonField's click

 

but  after one call when I am calling reset() on the DateTimePicker object second time, it doesn't shows up. 

 

Is it reinitialized by reset() method or not ? 

 

In my case it doesn't shows up, so I am recreating it.

 

public void fieldChanged(Field field, int context)
	{
		if (field == calendarBtn)
		{
			if(!isFirstTime)
			{	
				dateTimePicker1 = getDateTimePicker();
				UiApplication.getUiApplication().invokeLater(new Runnable()
				{
					public void run()
					{		
						if(dateTimePicker1.doModal())
						{
							Dialog.alert("Ok clicked first time");
						}
						else
						{
							Dialog.alert("Cancel clicked first time");
						}
						isFirstTime = true;						
					}
				});
			}
			else
			{	
				// dateTimePicker1.reset();      // doesn't work while trying to reinitialize that's why with no use of reset() method else condition is redundant and not required.
				dateTimePicker1 = getDateTimePicker();
				UiApplication.getUiApplication().invokeLater(new Runnable()
				{
					public void run()
					{		
						if(dateTimePicker1.doModal())
						{
							Dialog.alert("Ok clicked other time");
						}
						else
						{
							Dialog.alert("Cancel clicked other time");
						}
					}
				});
			}			
		}

	}

 

private DateTimePicker getDateTimePicker()
	{
		DateTimePicker dateTimePicker = DateTimePicker.createInstance(Calendar.getInstance());
		return dateTimePicker;
	}

 

 

Always Success