[英]How to pass an Element of DOM in xml to another activities
XPath xpath = XPathFactory.newInstance().newXPath();
String expression = "...";
EmParent = (Element) xpath.compile(expression).evaluate(Doc,XPathConstants.NODE);
Intent intent = new Intent(com.FSC.xml.MainActivity.this,com.FSC.xml.FileForm.class);
intent.putExtra("Em", EmParent)
startActivity(intent);
You can't pass nonParcelable or nonSerializable objects into the Intent
. 您不能将不可Parcelable或不可序列化的对象传递到Intent
。 Here is similar question . 这是类似的问题 。
But if you know structure of the EmParent
class 但是如果您知道EmParent
类的结构
First , you can create a wrapper class which will extend Parcelable
or implement Serializable
and converter method which converts EmParent
into EmParentWrapper
and then pass it into intent
. 首先 ,您可以创建一个包装器类,该类将扩展Parcelable
或实现Serializable
和converter方法,该方法将EmParent
转换为EmParentWrapper
,然后将其传递给intent
。
Second , is to put in the intent
data from you element by names(of course if you know it) 其次 ,是按名称放入您元素的intent
数据(当然,如果您知道的话)
Intent intent = new Intent();
intent.putExtra("FirstAttr", element.getAttribute("FirstAttr"));
intent.putExtra("SecondAttr", element.getAttribute("SecondAttr"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.