-1

How do you pass an object between views in an android application. I have googled and found that your class needs to implement the appropriate interface. How though do we do it if we do not own the class/object type we are passing (for example from an external library or a random class within the sdk)

I need to pass a HtmlSelect item object (from HtmlUnit open source project) to another class to process it but I cant bundle it up.

Thanks

4

2 回答 2

1

我最好的猜测是你创建一个静态帮助对象并像这样传递它。

HelperObject class {
    static HtmlSelect myHtmlObject
}

源活动:

HelperObject.myHtmlObject = currentHtlmlObject;
startActivity(intent);

目的地活动:

onCreate() {
    HtmlSelect htmlSelect = "create a copy copy of HelperObject.myHtmlObject not to have problems and then set it to null"
}
于 2012-06-22T15:30:18.843 回答
-1

只需使用putExtra()您的方法Intent来传递参数。

有时您需要首先将对象“解构”为简单元素(字符串、整数),然后在另一端使用getExtras().

于 2012-06-22T15:31:10.750 回答