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
Contributor
Posts: 33
Registered: ‎12-03-2011
My Device: 9800
My Carrier: Blackberry

How to enable save ,cancel, prompt when edit any field on back

I have an applicaation on which i have an edit fied.when i have done edit .it done.but on back button no save cancel discard prompt show.please suggest me how to enable it. 

Developer
Posts: 110
Registered: ‎10-22-2009
My Device: 9700
My Carrier: ChinaMobile

Re: How to enable save ,cancel, prompt when edit any field on back

did u extands from MainScreen?

 

or u can do some code by

 

protected boolean onSavePrompt()

 

Best Regards,
Tiandi
www.tiandiyoyo.com
Contributor
Posts: 33
Registered: ‎12-03-2011
My Device: 9800
My Carrier: Blackberry

Re: How to enable save ,cancel, prompt when edit any field on back

Yes sir i extend from mainscreen.....what i will do from onSavePrompt()

 

i have done following code on onSavePrompt()
 

public boolean onSavePrompt(){
savePreference();
return true;
}

Developer
Posts: 179
Registered: ‎06-15-2011
My Device: Storm 9550
My Carrier: Vodaphone

Re: How to enable save ,cancel, prompt when edit any field on back

You should remove onSavePrompt().

Contributor
Posts: 33
Registered: ‎12-03-2011
My Device: 9800
My Carrier: Blackberry

Re: How to enable save ,cancel, prompt when edit any field on back

then how  i will save my preference

Contributor
Posts: 33
Registered: ‎12-03-2011
My Device: 9800
My Carrier: Blackberry

Re: How to enable save ,cancel, prompt when edit any field on back

Not working after removing onSavePrompt()....still save without promt save

Highlighted
Developer
Posts: 110
Registered: ‎10-22-2009
My Device: 9700
My Carrier: ChinaMobile

Re: How to enable save ,cancel, prompt when edit any field on back

show some ur code.
Best Regards,
Tiandi
www.tiandiyoyo.com
Contributor
Posts: 33
Registered: ‎12-03-2011
My Device: 9800
My Carrier: Blackberry

Re: How to enable save ,cancel, prompt when edit any field on back

final class HelloWorldScreen extends MainScreen implements FieldChangeListener
{



HelloWorldScreen()
{


// Set the displayed title of the screen
setTitle("hello");



BasicEditField Name1EditField = new BasicEditField(
"",
preference.getMyName()[0],
105,
EditField.FILTER_UPPERCASE);
Name1EditField.setChangeListener(new FieldChangeListener(){
public void fieldChanged(Field field, int context)
{
String text = ((BasicEditField)field).getText();

}
});
vfm.add(msg1EditField);
private static void savePreference()
{
synchronized( persist )
{
persist.commit();
}
}


private void run() {
// TODO Auto-generated method stub

}


/**
* Displays a dialog box to the user with the text "Goodbye!" when the
* application is closed.
*
* @see net.rim.device.api.ui.Screen#close()
*/
public void close()
{
// Display a farewell message before closing the application
//Dialog.alert("Goodbye!");
super.close();
}

public boolean onSavePrompt(){
savePreference();
return true;
}


/**
* FieldChangeListener implementation. Displays a popup informing the user
* of what button was clicked.
* @see net.rim.device.api.ui.FieldChangeListener#fieldChanged(Field, int)
*/
form(text + " was clicked.");
}

}