![](/img/trans.png)
[英]How to Call Method in Activity From Other Class not Activity in Android?
[英]Call overridden method of Activity from other class
嗨,我有一個Interface
和一個Activity
。
我的活動實現了該接口,並覆蓋了接口的方法。
現在,我必須從另一個類調用該接口的重寫方法,以便執行活動的重寫方法。
提前致謝...
我可以從其他類中調用Activity的重寫方法為
((name of Interface) context).documentRead(dataUnit);
只需共享實現接口的活動的引用作為接口的對象,然后簡單地在該引用上調用被覆蓋的方法 。 基本的OOP概念。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.