public void save() {@SuppressWarnings("rawtypes")File file = new File(SYSSETPATH);if (file.exists())file.delete();try {ObjectOutputStream objOutPutStream = new ObjectOutputStream(new FileOutputStream(file));objOutPutStream.writeObject(mSystemSet);objOutPutStream.close();} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}}
Protected void onexit () {New alertdialog. Builder (this). settitle (getstring (R. String. dlg_title). setmessage (getstring ("are you sure you want to exit? ")). Setpositivebutton (getstring (R. string. yes), new dialoginterface. onclicklistener () {@ overridepublic void onclick (dialoginterface dialog, int which) {setresult (MSG. systemexit); finish ();}}). setnegativebutton (getstring (R. string. no), null ). show ();}
When using the software, you will often encounter clicking a button to bring up a window for us to select whether or not. Then, on Android, it becomes a dialog implementation instance. Today, I will write two examples for selecting a dialog.
Setmessage is the title of dialog, and setpostivebutton is one of the two buttons. It is defined as "yes" here, and the other one is the opposite, the onclick in the subsequent rewriting is very simple to select the corresponding button to post-process the event response, but it must be accumulated frequently. for Android beginners, It is accumulated step by step.
In addition, the objects that must be written to the writeobject in the objectoutputstream operation are serialized today. Otherwise, an exception is reported, that is, implements serializable can be used to define the object.
Private Static final long serialversionuid =-870520749171665437l; or Private Static final long serialversionuid = 1;