KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm just beginning to experiment with Android Development with SimpleXML and thought it was going quite well until I hit a snag. The code below produces an exception of W/System.err(665): org.simpleframework.xml.core.ConstructorException: Can not construct inner class I've looked through the questions on inner classes and think I understand why you would use them (not that mine was necessarily intentional) but despite moving my code round to try and avoid usage I'm still a little stuck and would appreciate any help. Source Code: public class InCaseOfEmergencyMedAlertAllergiesActivity extends Activity { public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); Serializer serializer = new Persister(); InputStream xmlstream = this.getResources().openRawResource(R.raw.sample_data_allergies); try { medalertdata allergyObject = serializer.read(medalertdata.class, xmlstream); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } setContentView(R.layout.allergies); } @Root public class medalertdata { @ElementList private List<allergy> allergyList; public List getAllergies() { return allergyList; } } @Root public class allergy{ @Element private String to; @Element private Boolean medical; @Element private String notes; public allergy(String to, Boolean medical, String notes){ this.to = to; this.medical = medical; this.notes = notes; } public String getTo() { return to; } public Boolean getMedical() { return medical; } public String getNotes() { return notes; } } } With the XML file referenced structured as: <?xml version="1.0" encoding="ISO-8859-1"?> <medalertdata> <allergy> <to>Peni
Tags (comma-separated)
Save Edits
Cancel