Using java Syntax Highlighting
- protected Dialog onCreateDialog(int id, Context ctx) {
- FileInputStream istream = null;
- try {
- istream = (FileInputStream) ctx.getResources().openRawResource(R.xml.sample);
- /* Get a SAXParser from the SAXPArserFactory. */
- SAXParserFactory spf = SAXParserFactory.newInstance();
- SAXParser sp = spf.newSAXParser();
- /* Get the XMLReader of the SAXParser we created. */
- XMLReader xr = sp.getXMLReader();
- /* Create a new ContentHandler and apply it to the XML-Reader*/
- ExampleHandler myExampleHandler = new ExampleHandler();
- xr.setContentHandler(myExampleHandler);
- /* Parse the xml-data from our URL. */
- xr.parse(new InputSource(istream));
- /* Parsing has finished. */
- /* Our ExampleHandler now provides the parsed data to us. */
- ParsedExampleDataSet parsedExampleDataSet = myExampleHandler.getParsedData();
- switch (id) {
- case DIALOG_MESSAGE:
- return new AlertDialog.Builder(MainMenu.this)
- //.setIcon(R.drawable.dialog_icon)
- .setTitle("Test set text from local file")
- .setMessage(parsedExampleDataSet.toString1())
- .setPositiveButton("OK", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- /* User clicked OK so do some stuff */
- }
- })
- .setNeutralButton("Something", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- /* User clicked Something so do some stuff */
- }
- })
- .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- /* User clicked Cancel so do some stuff */
- }
- })
- .create();
- }
- }
- catch (Exception e){
- e.getMessage();
- }
- return null;
- }
Parsed in 0.038 seconds, using GeSHi 1.0.8.4
I don't know that what is the problem in here? When I run the application which don't have error, so I click the button to call the function - it's error.
Thanks.

